mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Merge pull request #32429 from microsoft/jsDocTokenParsing
Fix missing tokenToString for the backtick token
This commit is contained in:
@@ -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) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user