Skip to content

Make tokenToString return string|undefined#16106

Merged
mhegazy merged 1 commit into
microsoft:masterfrom
ajafff:tokenToString
Jun 2, 2017
Merged

Make tokenToString return string|undefined#16106
mhegazy merged 1 commit into
microsoft:masterfrom
ajafff:tokenToString

Conversation

@ajafff
Copy link
Copy Markdown
Contributor

@ajafff ajafff commented May 26, 2017

Makes the tokenToString API compatible with strictNullChecks

Comment thread src/compiler/scanner.ts
const tokenStrings = makeReverseMap(textToToken);

export function tokenToString(t: SyntaxKind): string {
export function tokenToString(t: SyntaxKind): string | undefined {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would it return undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass a SyntaxKind of a Node. And even if you only pass SyntaxKind of Tokens, you get undefined for example for StringLiteral, NumericLiteral, etc.

@mhegazy mhegazy merged commit e8f42c4 into microsoft:master Jun 2, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants