Skip to content

Fix missing tokenToString for the backtick token #32429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ namespace ts {
"|=": SyntaxKind.BarEqualsToken,
"^=": SyntaxKind.CaretEqualsToken,
"@": SyntaxKind.AtToken,
"`": SyntaxKind.BacktickToken
});

/*
Expand Down Expand Up @@ -298,7 +299,6 @@ namespace ts {
}

const tokenStrings = makeReverseMap(textToToken);

export function tokenToString(t: SyntaxKind): string | undefined {
return tokenStrings[t];
}
Expand Down
15 changes: 15 additions & 0 deletions src/testRunner/unittests/publicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
20 changes: 20 additions & 0 deletions tests/baselines/reference/jsdocParameterParsingInvalidName.js
Original file line number Diff line number Diff line change
@@ -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;
}());
12 changes: 12 additions & 0 deletions tests/baselines/reference/jsdocParameterParsingInvalidName.symbols
Original file line number Diff line number Diff line change
@@ -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))
}
}
12 changes: 12 additions & 0 deletions tests/baselines/reference/jsdocParameterParsingInvalidName.types
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions tests/cases/compiler/jsdocParameterParsingInvalidName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class c {
/**
* @param {string} [`foo]
*/
method(foo) {
}
}