Skip to content

Commit 9f404e4

Browse files
committed
refactor(@angular/build): replace switch statements with Array.includes() in extension helpers
Replace switch-based extension checks in hasTemplateExtension and hasTypeScriptExtension with Array.prototype.includes() for better readability and conciseness.
1 parent 0f809d3 commit 9f404e4

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

packages/angular/build/src/tools/angular/angular-host.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -262,28 +262,9 @@ export function createAngularCompilerHost(
262262
}
263263

264264
function hasTemplateExtension(file: string): boolean {
265-
const extension = nodePath.extname(file).toLowerCase();
266-
267-
switch (extension) {
268-
case '.htm':
269-
case '.html':
270-
case '.svg':
271-
return true;
272-
}
273-
274-
return false;
265+
return ['.htm', '.html', '.svg'].includes(nodePath.extname(file).toLowerCase());
275266
}
276267

277268
function hasTypeScriptExtension(file: string): boolean {
278-
const extension = nodePath.extname(file).toLowerCase();
279-
280-
switch (extension) {
281-
case '.ts':
282-
case '.tsx':
283-
case '.mts':
284-
case '.cts':
285-
return true;
286-
}
287-
288-
return false;
269+
return ['.ts', '.tsx', '.mts', '.cts'].includes(nodePath.extname(file).toLowerCase());
289270
}

0 commit comments

Comments
 (0)