Skip to content

Commit 2da73b3

Browse files
committed
Change to getScriptKindFromFileName to avoid unnecessary array allocation in split
1 parent 11acf3a commit 2da73b3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/compiler/parser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,15 @@ namespace ts {
409409

410410
/* @internal */
411411
export function getScriptKindFromFileName(fileName: string): ScriptKind {
412-
const ext = fileName.split(".").pop();
412+
const ext = fileName.substr(fileName.lastIndexOf("."));
413413
switch (ext.toLowerCase()) {
414-
case "js":
414+
case ".js":
415415
return ScriptKind.JS;
416-
case "jsx":
416+
case ".jsx":
417417
return ScriptKind.JSX;
418-
case "ts":
418+
case ".ts":
419419
return ScriptKind.TS;
420-
case "tsx":
420+
case ".tsx":
421421
return ScriptKind.TSX;
422422
default:
423423
return ScriptKind.TS;

0 commit comments

Comments
 (0)