Skip to content

Commit 607c9c5

Browse files
committed
Fix missing tokenToString for the backtick
Fixes microsoft#32073
1 parent 10f3063 commit 607c9c5

File tree

6 files changed

+67
-1
lines changed

6 files changed

+67
-1
lines changed

src/compiler/scanner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ namespace ts {
197197
"|=": SyntaxKind.BarEqualsToken,
198198
"^=": SyntaxKind.CaretEqualsToken,
199199
"@": SyntaxKind.AtToken,
200+
"`": SyntaxKind.BacktickToken
200201
});
201202

202203
/*
@@ -298,7 +299,6 @@ namespace ts {
298299
}
299300

300301
const tokenStrings = makeReverseMap(textToToken);
301-
302302
export function tokenToString(t: SyntaxKind): string | undefined {
303303
return tokenStrings[t];
304304
}

src/testRunner/unittests/publicApi.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,18 @@ describe("Public APIs", () => {
3131
verifyApi("tsserverlibrary.d.ts");
3232
});
3333
});
34+
35+
describe("Public APIs:: token to string", () => {
36+
function assertDefinedTokenToString(initial: ts.SyntaxKind, last: ts.SyntaxKind) {
37+
for (let t = initial; t <= last; t++) {
38+
assert.isDefined(ts.tokenToString(t), `Expected tokenToString defined for ${ts.Debug.formatSyntaxKind(t)}`);
39+
}
40+
}
41+
42+
it("for punctuations", () => {
43+
assertDefinedTokenToString(ts.SyntaxKind.FirstPunctuation, ts.SyntaxKind.LastPunctuation);
44+
});
45+
it("for keywords", () => {
46+
assertDefinedTokenToString(ts.SyntaxKind.FirstKeyword, ts.SyntaxKind.LastKeyword);
47+
});
48+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//// [jsdocParameterParsingInvalidName.ts]
2+
class c {
3+
/**
4+
* @param {string} [`foo]
5+
*/
6+
method(foo) {
7+
}
8+
}
9+
10+
//// [jsdocParameterParsingInvalidName.js]
11+
var c = /** @class */ (function () {
12+
function c() {
13+
}
14+
/**
15+
* @param {string} [`foo]
16+
*/
17+
c.prototype.method = function (foo) {
18+
};
19+
return c;
20+
}());
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/compiler/jsdocParameterParsingInvalidName.ts ===
2+
class c {
3+
>c : Symbol(c, Decl(jsdocParameterParsingInvalidName.ts, 0, 0))
4+
5+
/**
6+
* @param {string} [`foo]
7+
*/
8+
method(foo) {
9+
>method : Symbol(c.method, Decl(jsdocParameterParsingInvalidName.ts, 0, 9))
10+
>foo : Symbol(foo, Decl(jsdocParameterParsingInvalidName.ts, 4, 11))
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/compiler/jsdocParameterParsingInvalidName.ts ===
2+
class c {
3+
>c : c
4+
5+
/**
6+
* @param {string} [`foo]
7+
*/
8+
method(foo) {
9+
>method : (foo: any) => void
10+
>foo : any
11+
}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class c {
2+
/**
3+
* @param {string} [`foo]
4+
*/
5+
method(foo) {
6+
}
7+
}

0 commit comments

Comments
 (0)