File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3915,7 +3915,7 @@ export function createScanner(
39153915
39163916 if ( isIdentifierStart ( ch , languageVersion ) ) {
39173917 let char = ch ;
3918- while ( pos < end && isIdentifierPart ( char = codePointUnchecked ( pos ) , languageVersion ) || char === CharacterCodes . minus ) pos += charSize ( char ) ;
3918+ while ( pos < end && ( isIdentifierPart ( char = codePointUnchecked ( pos ) , languageVersion ) || char === CharacterCodes . minus ) ) pos += charSize ( char ) ;
39193919 tokenValue = text . substring ( tokenStart , pos ) ;
39203920 if ( char === CharacterCodes . backslash ) {
39213921 tokenValue += scanIdentifierParts ( ) ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ describe("comment parsing", () => {
1111 const withTrailing = `;/* comment */
1212// another one
1313` ;
14+ const endingInHyphen = "/**comment-*/" ;
1415 it ( "skips shebang" , ( ) => {
1516 const result = ts . getLeadingCommentRanges ( withShebang , 0 ) ;
1617 assert . isDefined ( result ) ;
@@ -29,4 +30,16 @@ describe("comment parsing", () => {
2930 assert . strictEqual ( result . length , 1 ) ;
3031 assert . strictEqual ( result [ 0 ] . kind , ts . SyntaxKind . SingleLineCommentTrivia ) ;
3132 } ) ;
33+
34+ it ( "parses /** block comments ending in hyphen" , ( ) => {
35+ const sourceFile = ts . createSourceFile (
36+ "file.ts" ,
37+ `${ endingInHyphen } \nconst x = 1;` ,
38+ ts . ScriptTarget . ESNext ,
39+ /*setParentNodes*/ true ,
40+ ) ;
41+
42+ assert . strictEqual ( sourceFile . parseDiagnostics . length , 0 ) ;
43+ assert . strictEqual ( sourceFile . statements . length , 1 ) ;
44+ } ) ;
3245} ) ;
You can’t perform that action at this time.
0 commit comments