Merge pull request #32429 from microsoft/jsDocTokenParsing

Fix missing tokenToString for the backtick token
This commit is contained in:
Sheetal Nandi 2019-07-16 14:10:37 -07:00 committed by GitHub
commit d4765523f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 1 deletions

View file

@ -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];
}

View file

@ -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);
});
});

View file

@ -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;
}());

View file

@ -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))
}
}

View file

@ -0,0 +1,12 @@
=== tests/cases/compiler/jsdocParameterParsingInvalidName.ts ===
class c {
>c : c
/**
* @param {string} [`foo]
*/
method(foo) {
>method : (foo: any) => void
>foo : any
}
}

View file

@ -0,0 +1,7 @@
class c {
/**
* @param {string} [`foo]
*/
method(foo) {
}
}