Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3915,7 +3915,7 @@ export function createScanner(

if (isIdentifierStart(ch, languageVersion)) {
let char = ch;
while (pos < end && (isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus)) pos += charSize(char);
while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus) pos += charSize(char);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parentheses are easier to identify than the && operator. TypeScript was designed to make code easier for developers to read—hence the simple use of spacing and punctuation, and the goal of minimizing punctuation as much as possible.

tokenValue = text.substring(tokenStart, pos);
if (char === CharacterCodes.backslash) {
tokenValue += scanIdentifierParts();
Expand Down
13 changes: 0 additions & 13 deletions src/testRunner/unittests/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe("comment parsing", () => {
const withTrailing = `;/* comment */
// another one
`;
const endingInHyphen = "/**comment-*/";
it("skips shebang", () => {
const result = ts.getLeadingCommentRanges(withShebang, 0);
assert.isDefined(result);
Expand All @@ -30,16 +29,4 @@ describe("comment parsing", () => {
assert.strictEqual(result.length, 1);
assert.strictEqual(result[0].kind, ts.SyntaxKind.SingleLineCommentTrivia);
});

it("parses /** block comments ending in hyphen", () => {
const sourceFile = ts.createSourceFile(
"file.ts",
`${endingInHyphen}\nconst x = 1;`,
ts.ScriptTarget.ESNext,
/*setParentNodes*/ true,
);

assert.strictEqual(sourceFile.parseDiagnostics.length, 0);
assert.strictEqual(sourceFile.statements.length, 1);
});
});