Merge pull request #32429 from microsoft/jsDocTokenParsing
Fix missing tokenToString for the backtick token
This commit is contained in:
commit
d4765523f0
6 changed files with 67 additions and 1 deletions
|
@ -197,6 +197,7 @@ namespace ts {
|
|||
"|=": SyntaxKind.BarEqualsToken,
|
||||
"^=": SyntaxKind.CaretEqualsToken,
|
||||
"@": SyntaxKind.AtToken,
|
||||
"`": SyntaxKind.BacktickToken
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -298,7 +299,6 @@ namespace ts {
|
|||
}
|
||||
|
||||
const tokenStrings = makeReverseMap(textToToken);
|
||||
|
||||
export function tokenToString(t: SyntaxKind): string | undefined {
|
||||
return tokenStrings[t];
|
||||
}
|
||||
|
|
|
@ -31,3 +31,18 @@ describe("Public APIs", () => {
|
|||
verifyApi("tsserverlibrary.d.ts");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Public APIs:: token to string", () => {
|
||||
function assertDefinedTokenToString(initial: ts.SyntaxKind, last: ts.SyntaxKind) {
|
||||
for (let t = initial; t <= last; t++) {
|
||||
assert.isDefined(ts.tokenToString(t), `Expected tokenToString defined for ${ts.Debug.formatSyntaxKind(t)}`);
|
||||
}
|
||||
}
|
||||
|
||||
it("for punctuations", () => {
|
||||
assertDefinedTokenToString(ts.SyntaxKind.FirstPunctuation, ts.SyntaxKind.LastPunctuation);
|
||||
});
|
||||
it("for keywords", () => {
|
||||
assertDefinedTokenToString(ts.SyntaxKind.FirstKeyword, ts.SyntaxKind.LastKeyword);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
//// [jsdocParameterParsingInvalidName.ts]
|
||||
class c {
|
||||
/**
|
||||
* @param {string} [`foo]
|
||||
*/
|
||||
method(foo) {
|
||||
}
|
||||
}
|
||||
|
||||
//// [jsdocParameterParsingInvalidName.js]
|
||||
var c = /** @class */ (function () {
|
||||
function c() {
|
||||
}
|
||||
/**
|
||||
* @param {string} [`foo]
|
||||
*/
|
||||
c.prototype.method = function (foo) {
|
||||
};
|
||||
return c;
|
||||
}());
|
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/compiler/jsdocParameterParsingInvalidName.ts ===
|
||||
class c {
|
||||
>c : Symbol(c, Decl(jsdocParameterParsingInvalidName.ts, 0, 0))
|
||||
|
||||
/**
|
||||
* @param {string} [`foo]
|
||||
*/
|
||||
method(foo) {
|
||||
>method : Symbol(c.method, Decl(jsdocParameterParsingInvalidName.ts, 0, 9))
|
||||
>foo : Symbol(foo, Decl(jsdocParameterParsingInvalidName.ts, 4, 11))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/compiler/jsdocParameterParsingInvalidName.ts ===
|
||||
class c {
|
||||
>c : c
|
||||
|
||||
/**
|
||||
* @param {string} [`foo]
|
||||
*/
|
||||
method(foo) {
|
||||
>method : (foo: any) => void
|
||||
>foo : any
|
||||
}
|
||||
}
|
7
tests/cases/compiler/jsdocParameterParsingInvalidName.ts
Normal file
7
tests/cases/compiler/jsdocParameterParsingInvalidName.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
class c {
|
||||
/**
|
||||
* @param {string} [`foo]
|
||||
*/
|
||||
method(foo) {
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue