Skip to content

Commit e0a7627

Browse files
committed
CR feedback
1 parent 9754ec1 commit e0a7627

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/compiler/scanner.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ namespace ts {
538538
return pos;
539539
}
540540

541-
let shebangTriviaRegex = /^#!.*/;
541+
const shebangTriviaRegex = /^#!.*/;
542542

543543
function isShebangTrivia(text: string, pos: number) {
544544
// Shebangs check must only be done at the start of the file
@@ -644,12 +644,9 @@ namespace ts {
644644

645645
/** Optionally, get the shebang */
646646
export function getShebang(text: string): string {
647-
if (!shebangTriviaRegex.test(text)) {
648-
return undefined;
649-
}
650-
else {
651-
return shebangTriviaRegex.exec(text)[0];
652-
}
647+
return shebangTriviaRegex.test(text)
648+
? shebangTriviaRegex.exec(text)[0]
649+
: undefined;
653650
}
654651

655652
export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean {
@@ -1123,7 +1120,7 @@ namespace ts {
11231120
let ch = text.charCodeAt(pos);
11241121

11251122
// Special handling for shebang
1126-
if (ch == CharacterCodes.hash && pos === 0 && isShebangTrivia(text, pos)) {
1123+
if (ch === CharacterCodes.hash && pos === 0 && isShebangTrivia(text, pos)) {
11271124
pos = scanShebangTrivia(text ,pos);
11281125
if (skipTrivia) {
11291126
continue;

0 commit comments

Comments
 (0)