Skip to content
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

tests(ast-spec): make PunctuatorTokenToText more type-safe #3529

Merged
merged 1 commit into from Jun 21, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -44,6 +44,8 @@ export interface PunctuatorTokenToText {
[SyntaxKind.ColonToken]: ':';
[SyntaxKind.AtToken]: '@';
[SyntaxKind.QuestionQuestionToken]: '??';
[SyntaxKind.BacktickToken]: '`';
// [SyntaxKind.HashToken]: '#'; // new in PunctuationSyntaxKind in TS 4.4
[SyntaxKind.EqualsToken]: '=';
[SyntaxKind.PlusEqualsToken]: '+=';
[SyntaxKind.MinusEqualsToken]: '-=';
Expand All @@ -56,8 +58,8 @@ export interface PunctuatorTokenToText {
[SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken]: '>>>=';
[SyntaxKind.AmpersandEqualsToken]: '&=';
[SyntaxKind.BarEqualsToken]: '|=';
[SyntaxKind.BarBarEqualsToken]: '||=';
[SyntaxKind.AmpersandAmpersandEqualsToken]: '&&=';
[SyntaxKind.QuestionQuestionEqualsToken]: '??=';
[SyntaxKind.BarBarEqualsToken]: '||='; // included in PunctuationSyntaxKind in TS 4.4
[SyntaxKind.AmpersandAmpersandEqualsToken]: '&&='; // included in PunctuationSyntaxKind in TS 4.4
[SyntaxKind.QuestionQuestionEqualsToken]: '??='; // included in PunctuationSyntaxKind in TS 4.4
[SyntaxKind.CaretEqualsToken]: '^=';
}
11 changes: 11 additions & 0 deletions packages/ast-spec/tests/PunctuatorTokenToText.test.ts
@@ -0,0 +1,11 @@
import type { PunctuationSyntaxKind } from 'typescript';

import type { PunctuatorTokenToText } from '../src';

// @ts-expect-error: purposely unused
type _Test = {
readonly [T in PunctuationSyntaxKind]: PunctuatorTokenToText[T];
// If there are any PunctuationSyntaxKind members that don't have a
bradzacher marked this conversation as resolved.
Show resolved Hide resolved
// corresponding PunctuatorTokenToText, then this line will error with
// "Type 'T' cannot be used to index type 'PunctuatorTokenToText'."
bradzacher marked this conversation as resolved.
Show resolved Hide resolved
};