From 5ab307f9f737927a491f5924daf6600201f35cef Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Wed, 9 Nov 2022 09:56:17 +0800 Subject: [PATCH] `as tuple` type assertion --- src/compiler/checker.ts | 39 +- src/compiler/diagnosticMessages.json | 4 + src/compiler/factory/nodeFactory.ts | 1 + src/compiler/scanner.ts | 1 + src/compiler/types.ts | 2 + src/compiler/utilitiesPublic.ts | 9 + src/harness/fourslashInterfaceImpl.ts | 3 + src/services/classifier.ts | 4 +- src/services/completions.ts | 10 +- src/services/services.ts | 4 +- src/services/symbolDisplay.ts | 4 +- .../reference/api/tsserverlibrary.d.ts | 439 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 439 +++++++++--------- .../quickInfoForTupleAssertions.baseline | 170 +++++++ .../reference/tupleAssertions.errors.txt | 64 +++ tests/baselines/reference/tupleAssertions.js | 94 ++++ .../reference/tupleAssertions.symbols | 112 +++++ .../baselines/reference/tupleAssertions.types | 174 +++++++ .../typeAssertions/tupleAssertions.ts | 35 ++ .../fourslash/quickInfoForTupleAssertions.ts | 5 + .../semanticClassificationTupleAssertion.ts | 22 + 21 files changed, 1179 insertions(+), 456 deletions(-) create mode 100644 tests/baselines/reference/quickInfoForTupleAssertions.baseline create mode 100644 tests/baselines/reference/tupleAssertions.errors.txt create mode 100644 tests/baselines/reference/tupleAssertions.js create mode 100644 tests/baselines/reference/tupleAssertions.symbols create mode 100644 tests/baselines/reference/tupleAssertions.types create mode 100644 tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts create mode 100644 tests/cases/fourslash/quickInfoForTupleAssertions.ts create mode 100644 tests/cases/fourslash/semanticClassificationTupleAssertion.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 310dbacba3aae..6b83c49caeb36 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -89,7 +89,7 @@ import { isCatchClauseVariableDeclarationOrBindingElement, isCheckJsEnabledForFile, isChildOfNodeWithKind, isClassDeclaration, isClassElement, isClassExpression, isClassLike, isClassStaticBlockDeclaration, isCommaSequence, isCommonJsExportedExpression, isCommonJsExportPropertyAssignment, isComputedNonLiteralName, isComputedPropertyName, - isConstructorDeclaration, isConstructorTypeNode, isConstTypeReference, isDeclaration, isDeclarationName, + isConstructorDeclaration, isConstructorTypeNode, isConstTypeReference, isTupleTypeReference, isConstOrTupleTypeReference, isDeclaration, isDeclarationName, isDeclarationReadonly, isDecorator, isDefaultedExpandoInitializer, isDeleteTarget, isDottedName, isDynamicName, isEffectiveExternalModule, isElementAccessExpression, isEntityName, isEntityNameExpression, isEnumConst, isEnumDeclaration, isEnumMember, isExclusivelyTypeOnlyImportOrExport, isExportAssignment, isExportDeclaration, @@ -2038,6 +2038,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { || (isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression)); } + function isTupleAssertion(location: Node) { + return (isAssertionExpression(location) && isTupleTypeReference(location.type)) + || (isJSDocTypeTag(location) && isTupleTypeReference(location.typeExpression)); + } + /** * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -2080,7 +2085,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let isInExternalModule = false; loop: while (location) { - if (name === "const" && isConstAssertion(location)) { + if (name === "const" && isConstAssertion(location) || name === "tuple" && isTupleAssertion(location)) { // `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type // (it refers to the constant type of the expression instead) return undefined; @@ -14322,9 +14327,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const links = getNodeLinks(node); if (!links.resolvedType) { // handle LS queries on the `const` in `x as const` by resolving to the type of `x` - if (isConstTypeReference(node) && isAssertionExpression(node.parent)) { + if (isConstOrTupleTypeReference(node) && isAssertionExpression(node.parent)) { links.resolvedSymbol = unknownSymbol; - return links.resolvedType = checkExpressionCached(node.parent.expression); + return links.resolvedType = checkExpressionCached(node.parent.expression, /*checkMode*/ undefined, /*forceTuple*/ isTupleTypeReference(node)); } let symbol: Symbol | undefined; let type: Type | undefined; @@ -27856,7 +27861,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getContextualTypeForArgument(parent as CallExpression | NewExpression, node); case SyntaxKind.TypeAssertionExpression: case SyntaxKind.AsExpression: - return isConstTypeReference((parent as AssertionExpression).type) ? tryFindWhenConstTypeReference(parent as AssertionExpression) : getTypeFromTypeNode((parent as AssertionExpression).type); + return isConstOrTupleTypeReference((parent as AssertionExpression).type) ? tryFindWhenConstOrTupleTypeReference(parent as AssertionExpression) : getTypeFromTypeNode((parent as AssertionExpression).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node, contextFlags); case SyntaxKind.PropertyAssignment: @@ -27878,7 +27883,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. const tag = isInJSFile(parent) ? getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent as ParenthesizedExpression, contextFlags) : - isJSDocTypeTag(tag) && isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent as ParenthesizedExpression) : + isJSDocTypeTag(tag) && isConstOrTupleTypeReference(tag.typeExpression.type) ? tryFindWhenConstOrTupleTypeReference(parent as ParenthesizedExpression) : getTypeFromTypeNode(tag.typeExpression.type); } case SyntaxKind.NonNullExpression: @@ -27898,7 +27903,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } return undefined; - function tryFindWhenConstTypeReference(node: Expression) { + function tryFindWhenConstOrTupleTypeReference(node: Expression) { return getContextualType(node, contextFlags); } } @@ -32761,7 +32766,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return false; } + function isValidTupleAssertionArgument(node: Node): boolean { + return isArrayLiteralExpression(node) || isParenthesizedExpression(node) && isValidTupleAssertionArgument(node.expression); + } + function checkAssertionWorker(errNode: Node, type: TypeNode, expression: UnaryExpression | Expression, checkMode?: CheckMode) { + if (isTupleTypeReference(type)) { + if (!isValidTupleAssertionArgument(expression)) { + error(expression, Diagnostics.A_tuple_assertions_can_only_be_applied_to_array_literals); + } + return getRegularTypeOfLiteralType(checkExpression(expression, checkMode, /*forceTuple*/ true)); + } let exprType = checkExpression(expression, checkMode); if (isConstTypeReference(type)) { if (!isValidConstAssertionArgument(expression)) { @@ -35183,9 +35198,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function checkExpressionCached(node: Expression | QualifiedName, checkMode?: CheckMode): Type { + function checkExpressionCached(node: Expression | QualifiedName, checkMode?: CheckMode, forceTuple?: boolean): Type { if (checkMode) { - return checkExpression(node, checkMode); + return checkExpression(node, checkMode, forceTuple); } const links = getNodeLinks(node); if (!links.resolvedType) { @@ -35196,7 +35211,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const saveFlowTypeCache = flowTypeCache; flowLoopStart = flowLoopCount; flowTypeCache = undefined; - links.resolvedType = checkExpression(node, checkMode); + links.resolvedType = checkExpression(node, checkMode, forceTuple); flowTypeCache = saveFlowTypeCache; flowLoopStart = saveFlowLoopStart; } @@ -35508,7 +35523,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let expr = skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); if (isJSDocTypeAssertion(expr)) { const type = getJSDocTypeAssertionType(expr); - if (!isConstTypeReference(type)) { + if (!isConstOrTupleTypeReference(type)) { return getTypeFromTypeNode(type); } } @@ -35522,7 +35537,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return type; } } - else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) { + else if (isAssertionExpression(expr) && !isConstOrTupleTypeReference(expr.type)) { return getTypeFromTypeNode((expr as TypeAssertion).type); } else if (node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral || diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c0395bdfea0a4..7386091388385 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1549,6 +1549,10 @@ "category": "Message", "code": 1483 }, + "A 'tuple' assertions can only be applied to array literals.": { + "category": "Error", + "code": 1484 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index f2f111efb22c1..6388ad577c823 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -1123,6 +1123,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode case SyntaxKind.StringKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.TupleKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UnknownKeyword: case SyntaxKind.UndefinedKeyword: // `undefined` is an Identifier in the expression case. diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index ee1439635cd78..79871cf4af0a8 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -154,6 +154,7 @@ export const textToKeywordObj: MapLike = { throw: SyntaxKind.ThrowKeyword, true: SyntaxKind.TrueKeyword, try: SyntaxKind.TryKeyword, + tuple: SyntaxKind.TupleKeyword, type: SyntaxKind.TypeKeyword, typeof: SyntaxKind.TypeOfKeyword, undefined: SyntaxKind.UndefinedKeyword, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b754fb57f944f..2dbe83e9b3f6e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -191,6 +191,7 @@ export const enum SyntaxKind { SetKeyword, StringKeyword, SymbolKeyword, + TupleKeyword, TypeKeyword, UndefinedKeyword, UniqueKeyword, @@ -627,6 +628,7 @@ export type KeywordSyntaxKind = | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword + | SyntaxKind.TupleKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 03b172fa3e7f2..a495f8d726107 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1095,6 +1095,15 @@ export function isConstTypeReference(node: Node) { node.typeName.escapedText === "const" && !node.typeArguments; } +export function isTupleTypeReference(node: Node) { + return isTypeReferenceNode(node) && isIdentifier(node.typeName) && + node.typeName.escapedText === "tuple" && !node.typeArguments; +} + +export function isConstOrTupleTypeReference(node: Node) { + return isConstTypeReference(node) || isTupleTypeReference(node); +} + export function skipPartiallyEmittedExpressions(node: Expression): Expression; export function skipPartiallyEmittedExpressions(node: Node): Node; export function skipPartiallyEmittedExpressions(node: Node) { diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index 25889e77f4002..9fe572807df4a 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -1234,6 +1234,9 @@ export namespace Completion { export const typeAssertionKeywords: readonly ExpectedCompletionEntry[] = globalTypesPlus([keywordEntry("const")]); + export const typeAssertionKeywordsAfterArray: readonly ExpectedCompletionEntry[] = + globalTypesPlus([keywordEntry("const"), keywordEntry("tuple")]); + function getInJsKeywords(keywords: readonly ExpectedCompletionEntryObject[]): readonly ExpectedCompletionEntryObject[] { return keywords.filter(keyword => { switch (keyword.name) { diff --git a/src/services/classifier.ts b/src/services/classifier.ts index ebff8cc4473f5..5bcac14a82b3f 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -3,7 +3,7 @@ import { ClassificationResult, Classifications, ClassificationType, ClassificationTypeNames, ClassifiedSpan, Classifier, commentPragmas, couldStartTrivia, createScanner, createTextSpan, Debug, decodedTextSpanIntersectsWith, EndOfLineState, EnumDeclaration, getMeaningFromLocation, getModuleInstanceState, getTypeArgumentOrTypeParameterList, - HasJSDoc, InterfaceDeclaration, isAccessibilityModifier, isConstTypeReference, isIdentifier, isJSDoc, isKeyword, + HasJSDoc, InterfaceDeclaration, isAccessibilityModifier, isConstOrTupleTypeReference, isIdentifier, isJSDoc, isKeyword, isLineBreak, isModuleDeclaration, isPunctuation, isTemplateLiteralKind, isThisIdentifier, isToken, isTrivia, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, JSDocEnumTag, JSDocImplementsTag, JSDocParameterTag, JSDocPropertyTag, JSDocReturnTag, JSDocSeeTag, JSDocTemplateTag, JSDocThisTag, JSDocTypedefTag, JSDocTypeTag, JsxAttribute, @@ -1092,7 +1092,7 @@ export function getEncodedSyntacticClassifications(cancellationToken: Cancellati return; } - if (isConstTypeReference(token.parent)) { + if (isConstOrTupleTypeReference(token.parent)) { return ClassificationType.keyword; } } diff --git a/src/services/completions.ts b/src/services/completions.ts index a9d7b81dbfe25..5eda27f41d388 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -58,7 +58,7 @@ import { SymbolFlags, SymbolId, SyntaxKind, TextChange, textChanges, textPart, TextRange, TextSpan, timestamp, Token, TokenSyntaxKind, tokenToString, tryCast, tryGetImportFromModuleSpecifier, Type, TypeChecker, TypeElement, TypeFlags, typeHasCallOrConstructSignatures, TypeLiteralNode, TypeOnlyAliasDeclaration, unescapeLeadingUnderscores, - UnionReduction, UnionType, UserPreferences, VariableDeclaration, walkUpParenthesizedExpressions, + UnionReduction, UnionType, UserPreferences, VariableDeclaration, walkUpParenthesizedExpressions, isArrayLiteralExpression, } from "./_namespaces/ts"; import { StringCompletions } from "./_namespaces/ts.Completions"; @@ -240,6 +240,7 @@ const enum KeywordCompletionFilters { ConstructorParameterKeywords, // Keywords at constructor parameter FunctionLikeBodyKeywords, // Keywords at function like body TypeAssertionKeywords, + TypeAssertionKeywordsAfterArray, TypeKeywords, TypeKeyword, // Literally just `type` Last = TypeKeyword @@ -2693,7 +2694,9 @@ function getCompletionData( collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && isAssertionExpression(contextToken.parent) - ? KeywordCompletionFilters.TypeAssertionKeywords + ? isArrayLiteralExpression(walkUpParenthesizedExpressions(contextToken.parent.expression)) + ? KeywordCompletionFilters.TypeAssertionKeywordsAfterArray + : KeywordCompletionFilters.TypeAssertionKeywords : KeywordCompletionFilters.TypeKeywords; } } @@ -3985,6 +3988,8 @@ function getTypescriptKeywordCompletions(keywordFilter: KeywordCompletionFilters return isParameterPropertyModifier(kind); case KeywordCompletionFilters.TypeAssertionKeywords: return isTypeKeyword(kind) || kind === SyntaxKind.ConstKeyword; + case KeywordCompletionFilters.TypeAssertionKeywordsAfterArray: + return isTypeKeyword(kind) || kind === SyntaxKind.ConstKeyword || kind === SyntaxKind.TupleKeyword; case KeywordCompletionFilters.TypeKeywords: return isTypeKeyword(kind); case KeywordCompletionFilters.TypeKeyword: @@ -4021,6 +4026,7 @@ function isTypeScriptOnlyKeyword(kind: SyntaxKind) { case SyntaxKind.ReadonlyKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.TupleKeyword: case SyntaxKind.TypeKeyword: case SyntaxKind.UniqueKeyword: case SyntaxKind.UnknownKeyword: diff --git a/src/services/services.ts b/src/services/services.ts index 3380fe9ff2dcc..18e4ef3f04400 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -26,7 +26,7 @@ import { hasJSDocNodes, hasProperty, hasStaticModifier, hasSyntacticModifier, HighlightSpanKind, HostCancellationToken, hostGetCanonicalFileName, hostUsesCaseSensitiveFileNames, Identifier, identity, idText, ImplementationLocation, ImportDeclaration, IndexKind, IndexType, InlayHint, InlayHints, InlayHintsContext, insertSorted, InterfaceType, - IntersectionType, isArray, isBindingPattern, isComputedPropertyName, isConstTypeReference, IScriptSnapshot, + IntersectionType, isArray, isBindingPattern, isComputedPropertyName, isConstOrTupleTypeReference, IScriptSnapshot, isDeclarationName, isGetAccessor, isIdentifier, isImportMeta, isInComment, isInsideJsxElement, isInsideJsxElementOrAttribute, isInString, isInTemplateString, isIntrinsicJsxName, isJSDocCommentContainingNode, isJsxAttributes, isJsxClosingElement, isJsxElement, isJsxFragment, isJsxOpeningElement, isJsxOpeningFragment, @@ -1795,7 +1795,7 @@ export function createLanguageService( function shouldGetType(sourceFile: SourceFile, node: Node, position: number): boolean { switch (node.kind) { case SyntaxKind.Identifier: - return !isLabelName(node) && !isTagName(node) && !isConstTypeReference(node.parent); + return !isLabelName(node) && !isTagName(node) && !isConstOrTupleTypeReference(node.parent); case SyntaxKind.PropertyAccessExpression: case SyntaxKind.QualifiedName: // Don't return quickInfo if inside the comment in `a/**/.b` diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 9e627cae13319..01ebcfad4e765 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -5,7 +5,7 @@ import { getMeaningFromLocation, getNameOfDeclaration, getNodeModifiers, getObjectFlags, getParseTreeNode, getSourceFileOfNode, getTextOfConstantValue, getTextOfIdentifierOrLiteral, getTextOfNode, hasSyntacticModifier, idText, ImportEqualsDeclaration, isArrowFunction, isBindingElement, isCallExpression, isCallExpressionTarget, - isCallOrNewExpression, isClassExpression, isConstTypeReference, isDeprecatedDeclaration, isEnumConst, + isCallOrNewExpression, isClassExpression, isConstOrTupleTypeReference, isDeprecatedDeclaration, isEnumConst, isEnumDeclaration, isExpression, isExternalModuleImportEqualsDeclaration, isFirstDeclarationOfSymbolParameter, isFunctionBlock, isFunctionExpression, isFunctionLike, isFunctionLikeKind, isIdentifier, isInExpressionContext, isJsxOpeningLikeElement, isLet, isModuleWithStringLiteralName, isNameOfFunctionDeclaration, isNewExpressionTarget, @@ -364,7 +364,7 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); - addRange(displayParts, typeToDisplayParts(typeChecker, isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, TypeFormatFlags.InTypeAlias)); + addRange(displayParts, typeToDisplayParts(typeChecker, isConstOrTupleTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, TypeFormatFlags.InTypeAlias)); } if (symbolFlags & SymbolFlags.Enum) { prefixNextMeaning(); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 6a93d33726e1b..4d5c324153e51 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4211,213 +4211,214 @@ declare namespace ts { SetKeyword = 151, StringKeyword = 152, SymbolKeyword = 153, - TypeKeyword = 154, - UndefinedKeyword = 155, - UniqueKeyword = 156, - UnknownKeyword = 157, - FromKeyword = 158, - GlobalKeyword = 159, - BigIntKeyword = 160, - OverrideKeyword = 161, - OfKeyword = 162, - QualifiedName = 163, - ComputedPropertyName = 164, - TypeParameter = 165, - Parameter = 166, - Decorator = 167, - PropertySignature = 168, - PropertyDeclaration = 169, - MethodSignature = 170, - MethodDeclaration = 171, - ClassStaticBlockDeclaration = 172, - Constructor = 173, - GetAccessor = 174, - SetAccessor = 175, - CallSignature = 176, - ConstructSignature = 177, - IndexSignature = 178, - TypePredicate = 179, - TypeReference = 180, - FunctionType = 181, - ConstructorType = 182, - TypeQuery = 183, - TypeLiteral = 184, - ArrayType = 185, - TupleType = 186, - OptionalType = 187, - RestType = 188, - UnionType = 189, - IntersectionType = 190, - ConditionalType = 191, - InferType = 192, - ParenthesizedType = 193, - ThisType = 194, - TypeOperator = 195, - IndexedAccessType = 196, - MappedType = 197, - LiteralType = 198, - NamedTupleMember = 199, - TemplateLiteralType = 200, - TemplateLiteralTypeSpan = 201, - ImportType = 202, - ObjectBindingPattern = 203, - ArrayBindingPattern = 204, - BindingElement = 205, - ArrayLiteralExpression = 206, - ObjectLiteralExpression = 207, - PropertyAccessExpression = 208, - ElementAccessExpression = 209, - CallExpression = 210, - NewExpression = 211, - TaggedTemplateExpression = 212, - TypeAssertionExpression = 213, - ParenthesizedExpression = 214, - FunctionExpression = 215, - ArrowFunction = 216, - DeleteExpression = 217, - TypeOfExpression = 218, - VoidExpression = 219, - AwaitExpression = 220, - PrefixUnaryExpression = 221, - PostfixUnaryExpression = 222, - BinaryExpression = 223, - ConditionalExpression = 224, - TemplateExpression = 225, - YieldExpression = 226, - SpreadElement = 227, - ClassExpression = 228, - OmittedExpression = 229, - ExpressionWithTypeArguments = 230, - AsExpression = 231, - NonNullExpression = 232, - MetaProperty = 233, - SyntheticExpression = 234, - SatisfiesExpression = 235, - TemplateSpan = 236, - SemicolonClassElement = 237, - Block = 238, - EmptyStatement = 239, - VariableStatement = 240, - ExpressionStatement = 241, - IfStatement = 242, - DoStatement = 243, - WhileStatement = 244, - ForStatement = 245, - ForInStatement = 246, - ForOfStatement = 247, - ContinueStatement = 248, - BreakStatement = 249, - ReturnStatement = 250, - WithStatement = 251, - SwitchStatement = 252, - LabeledStatement = 253, - ThrowStatement = 254, - TryStatement = 255, - DebuggerStatement = 256, - VariableDeclaration = 257, - VariableDeclarationList = 258, - FunctionDeclaration = 259, - ClassDeclaration = 260, - InterfaceDeclaration = 261, - TypeAliasDeclaration = 262, - EnumDeclaration = 263, - ModuleDeclaration = 264, - ModuleBlock = 265, - CaseBlock = 266, - NamespaceExportDeclaration = 267, - ImportEqualsDeclaration = 268, - ImportDeclaration = 269, - ImportClause = 270, - NamespaceImport = 271, - NamedImports = 272, - ImportSpecifier = 273, - ExportAssignment = 274, - ExportDeclaration = 275, - NamedExports = 276, - NamespaceExport = 277, - ExportSpecifier = 278, - MissingDeclaration = 279, - ExternalModuleReference = 280, - JsxElement = 281, - JsxSelfClosingElement = 282, - JsxOpeningElement = 283, - JsxClosingElement = 284, - JsxFragment = 285, - JsxOpeningFragment = 286, - JsxClosingFragment = 287, - JsxAttribute = 288, - JsxAttributes = 289, - JsxSpreadAttribute = 290, - JsxExpression = 291, - CaseClause = 292, - DefaultClause = 293, - HeritageClause = 294, - CatchClause = 295, - AssertClause = 296, - AssertEntry = 297, - ImportTypeAssertionContainer = 298, - PropertyAssignment = 299, - ShorthandPropertyAssignment = 300, - SpreadAssignment = 301, - EnumMember = 302, - UnparsedPrologue = 303, - UnparsedPrepend = 304, - UnparsedText = 305, - UnparsedInternalText = 306, - UnparsedSyntheticReference = 307, - SourceFile = 308, - Bundle = 309, - UnparsedSource = 310, - InputFiles = 311, - JSDocTypeExpression = 312, - JSDocNameReference = 313, - JSDocMemberName = 314, - JSDocAllType = 315, - JSDocUnknownType = 316, - JSDocNullableType = 317, - JSDocNonNullableType = 318, - JSDocOptionalType = 319, - JSDocFunctionType = 320, - JSDocVariadicType = 321, - JSDocNamepathType = 322, - JSDoc = 323, + TupleKeyword = 154, + TypeKeyword = 155, + UndefinedKeyword = 156, + UniqueKeyword = 157, + UnknownKeyword = 158, + FromKeyword = 159, + GlobalKeyword = 160, + BigIntKeyword = 161, + OverrideKeyword = 162, + OfKeyword = 163, + QualifiedName = 164, + ComputedPropertyName = 165, + TypeParameter = 166, + Parameter = 167, + Decorator = 168, + PropertySignature = 169, + PropertyDeclaration = 170, + MethodSignature = 171, + MethodDeclaration = 172, + ClassStaticBlockDeclaration = 173, + Constructor = 174, + GetAccessor = 175, + SetAccessor = 176, + CallSignature = 177, + ConstructSignature = 178, + IndexSignature = 179, + TypePredicate = 180, + TypeReference = 181, + FunctionType = 182, + ConstructorType = 183, + TypeQuery = 184, + TypeLiteral = 185, + ArrayType = 186, + TupleType = 187, + OptionalType = 188, + RestType = 189, + UnionType = 190, + IntersectionType = 191, + ConditionalType = 192, + InferType = 193, + ParenthesizedType = 194, + ThisType = 195, + TypeOperator = 196, + IndexedAccessType = 197, + MappedType = 198, + LiteralType = 199, + NamedTupleMember = 200, + TemplateLiteralType = 201, + TemplateLiteralTypeSpan = 202, + ImportType = 203, + ObjectBindingPattern = 204, + ArrayBindingPattern = 205, + BindingElement = 206, + ArrayLiteralExpression = 207, + ObjectLiteralExpression = 208, + PropertyAccessExpression = 209, + ElementAccessExpression = 210, + CallExpression = 211, + NewExpression = 212, + TaggedTemplateExpression = 213, + TypeAssertionExpression = 214, + ParenthesizedExpression = 215, + FunctionExpression = 216, + ArrowFunction = 217, + DeleteExpression = 218, + TypeOfExpression = 219, + VoidExpression = 220, + AwaitExpression = 221, + PrefixUnaryExpression = 222, + PostfixUnaryExpression = 223, + BinaryExpression = 224, + ConditionalExpression = 225, + TemplateExpression = 226, + YieldExpression = 227, + SpreadElement = 228, + ClassExpression = 229, + OmittedExpression = 230, + ExpressionWithTypeArguments = 231, + AsExpression = 232, + NonNullExpression = 233, + MetaProperty = 234, + SyntheticExpression = 235, + SatisfiesExpression = 236, + TemplateSpan = 237, + SemicolonClassElement = 238, + Block = 239, + EmptyStatement = 240, + VariableStatement = 241, + ExpressionStatement = 242, + IfStatement = 243, + DoStatement = 244, + WhileStatement = 245, + ForStatement = 246, + ForInStatement = 247, + ForOfStatement = 248, + ContinueStatement = 249, + BreakStatement = 250, + ReturnStatement = 251, + WithStatement = 252, + SwitchStatement = 253, + LabeledStatement = 254, + ThrowStatement = 255, + TryStatement = 256, + DebuggerStatement = 257, + VariableDeclaration = 258, + VariableDeclarationList = 259, + FunctionDeclaration = 260, + ClassDeclaration = 261, + InterfaceDeclaration = 262, + TypeAliasDeclaration = 263, + EnumDeclaration = 264, + ModuleDeclaration = 265, + ModuleBlock = 266, + CaseBlock = 267, + NamespaceExportDeclaration = 268, + ImportEqualsDeclaration = 269, + ImportDeclaration = 270, + ImportClause = 271, + NamespaceImport = 272, + NamedImports = 273, + ImportSpecifier = 274, + ExportAssignment = 275, + ExportDeclaration = 276, + NamedExports = 277, + NamespaceExport = 278, + ExportSpecifier = 279, + MissingDeclaration = 280, + ExternalModuleReference = 281, + JsxElement = 282, + JsxSelfClosingElement = 283, + JsxOpeningElement = 284, + JsxClosingElement = 285, + JsxFragment = 286, + JsxOpeningFragment = 287, + JsxClosingFragment = 288, + JsxAttribute = 289, + JsxAttributes = 290, + JsxSpreadAttribute = 291, + JsxExpression = 292, + CaseClause = 293, + DefaultClause = 294, + HeritageClause = 295, + CatchClause = 296, + AssertClause = 297, + AssertEntry = 298, + ImportTypeAssertionContainer = 299, + PropertyAssignment = 300, + ShorthandPropertyAssignment = 301, + SpreadAssignment = 302, + EnumMember = 303, + UnparsedPrologue = 304, + UnparsedPrepend = 305, + UnparsedText = 306, + UnparsedInternalText = 307, + UnparsedSyntheticReference = 308, + SourceFile = 309, + Bundle = 310, + UnparsedSource = 311, + InputFiles = 312, + JSDocTypeExpression = 313, + JSDocNameReference = 314, + JSDocMemberName = 315, + JSDocAllType = 316, + JSDocUnknownType = 317, + JSDocNullableType = 318, + JSDocNonNullableType = 319, + JSDocOptionalType = 320, + JSDocFunctionType = 321, + JSDocVariadicType = 322, + JSDocNamepathType = 323, + JSDoc = 324, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 323, - JSDocText = 324, - JSDocTypeLiteral = 325, - JSDocSignature = 326, - JSDocLink = 327, - JSDocLinkCode = 328, - JSDocLinkPlain = 329, - JSDocTag = 330, - JSDocAugmentsTag = 331, - JSDocImplementsTag = 332, - JSDocAuthorTag = 333, - JSDocDeprecatedTag = 334, - JSDocClassTag = 335, - JSDocPublicTag = 336, - JSDocPrivateTag = 337, - JSDocProtectedTag = 338, - JSDocReadonlyTag = 339, - JSDocOverrideTag = 340, - JSDocCallbackTag = 341, - JSDocEnumTag = 342, - JSDocParameterTag = 343, - JSDocReturnTag = 344, - JSDocThisTag = 345, - JSDocTypeTag = 346, - JSDocTemplateTag = 347, - JSDocTypedefTag = 348, - JSDocSeeTag = 349, - JSDocPropertyTag = 350, - SyntaxList = 351, - NotEmittedStatement = 352, - PartiallyEmittedExpression = 353, - CommaListExpression = 354, - MergeDeclarationMarker = 355, - EndOfDeclarationMarker = 356, - SyntheticReferenceExpression = 357, - Count = 358, + JSDocComment = 324, + JSDocText = 325, + JSDocTypeLiteral = 326, + JSDocSignature = 327, + JSDocLink = 328, + JSDocLinkCode = 329, + JSDocLinkPlain = 330, + JSDocTag = 331, + JSDocAugmentsTag = 332, + JSDocImplementsTag = 333, + JSDocAuthorTag = 334, + JSDocDeprecatedTag = 335, + JSDocClassTag = 336, + JSDocPublicTag = 337, + JSDocPrivateTag = 338, + JSDocProtectedTag = 339, + JSDocReadonlyTag = 340, + JSDocOverrideTag = 341, + JSDocCallbackTag = 342, + JSDocEnumTag = 343, + JSDocParameterTag = 344, + JSDocReturnTag = 345, + JSDocThisTag = 346, + JSDocTypeTag = 347, + JSDocTemplateTag = 348, + JSDocTypedefTag = 349, + JSDocSeeTag = 350, + JSDocPropertyTag = 351, + SyntaxList = 352, + NotEmittedStatement = 353, + PartiallyEmittedExpression = 354, + CommaListExpression = 355, + MergeDeclarationMarker = 356, + EndOfDeclarationMarker = 357, + SyntheticReferenceExpression = 358, + Count = 359, FirstAssignment = 63, LastAssignment = 78, FirstCompoundAssignment = 64, @@ -4425,15 +4426,15 @@ declare namespace ts { FirstReservedWord = 81, LastReservedWord = 116, FirstKeyword = 81, - LastKeyword = 162, + LastKeyword = 163, FirstFutureReservedWord = 117, LastFutureReservedWord = 125, - FirstTypeNode = 179, - LastTypeNode = 202, + FirstTypeNode = 180, + LastTypeNode = 203, FirstPunctuation = 18, LastPunctuation = 78, FirstToken = 0, - LastToken = 162, + LastToken = 163, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -4442,19 +4443,19 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 78, - FirstStatement = 240, - LastStatement = 256, - FirstNode = 163, - FirstJSDocNode = 312, - LastJSDocNode = 350, - FirstJSDocTagNode = 330, - LastJSDocTagNode = 350 + FirstStatement = 241, + LastStatement = 257, + FirstNode = 164, + FirstJSDocNode = 313, + LastJSDocNode = 351, + FirstJSDocTagNode = 331, + LastJSDocTagNode = 351 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TupleKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; @@ -8748,6 +8749,8 @@ declare namespace ts { function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain | NonNullChain; function isNullishCoalesce(node: Node): boolean; function isConstTypeReference(node: Node): boolean; + function isTupleTypeReference(node: Node): boolean; + function isConstOrTupleTypeReference(node: Node): boolean; function skipPartiallyEmittedExpressions(node: Expression): Expression; function skipPartiallyEmittedExpressions(node: Node): Node; function isNonNullChain(node: Node): node is NonNullChain; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index cc0b9416ac78e..bcf8d1ff81be8 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -273,213 +273,214 @@ declare namespace ts { SetKeyword = 151, StringKeyword = 152, SymbolKeyword = 153, - TypeKeyword = 154, - UndefinedKeyword = 155, - UniqueKeyword = 156, - UnknownKeyword = 157, - FromKeyword = 158, - GlobalKeyword = 159, - BigIntKeyword = 160, - OverrideKeyword = 161, - OfKeyword = 162, - QualifiedName = 163, - ComputedPropertyName = 164, - TypeParameter = 165, - Parameter = 166, - Decorator = 167, - PropertySignature = 168, - PropertyDeclaration = 169, - MethodSignature = 170, - MethodDeclaration = 171, - ClassStaticBlockDeclaration = 172, - Constructor = 173, - GetAccessor = 174, - SetAccessor = 175, - CallSignature = 176, - ConstructSignature = 177, - IndexSignature = 178, - TypePredicate = 179, - TypeReference = 180, - FunctionType = 181, - ConstructorType = 182, - TypeQuery = 183, - TypeLiteral = 184, - ArrayType = 185, - TupleType = 186, - OptionalType = 187, - RestType = 188, - UnionType = 189, - IntersectionType = 190, - ConditionalType = 191, - InferType = 192, - ParenthesizedType = 193, - ThisType = 194, - TypeOperator = 195, - IndexedAccessType = 196, - MappedType = 197, - LiteralType = 198, - NamedTupleMember = 199, - TemplateLiteralType = 200, - TemplateLiteralTypeSpan = 201, - ImportType = 202, - ObjectBindingPattern = 203, - ArrayBindingPattern = 204, - BindingElement = 205, - ArrayLiteralExpression = 206, - ObjectLiteralExpression = 207, - PropertyAccessExpression = 208, - ElementAccessExpression = 209, - CallExpression = 210, - NewExpression = 211, - TaggedTemplateExpression = 212, - TypeAssertionExpression = 213, - ParenthesizedExpression = 214, - FunctionExpression = 215, - ArrowFunction = 216, - DeleteExpression = 217, - TypeOfExpression = 218, - VoidExpression = 219, - AwaitExpression = 220, - PrefixUnaryExpression = 221, - PostfixUnaryExpression = 222, - BinaryExpression = 223, - ConditionalExpression = 224, - TemplateExpression = 225, - YieldExpression = 226, - SpreadElement = 227, - ClassExpression = 228, - OmittedExpression = 229, - ExpressionWithTypeArguments = 230, - AsExpression = 231, - NonNullExpression = 232, - MetaProperty = 233, - SyntheticExpression = 234, - SatisfiesExpression = 235, - TemplateSpan = 236, - SemicolonClassElement = 237, - Block = 238, - EmptyStatement = 239, - VariableStatement = 240, - ExpressionStatement = 241, - IfStatement = 242, - DoStatement = 243, - WhileStatement = 244, - ForStatement = 245, - ForInStatement = 246, - ForOfStatement = 247, - ContinueStatement = 248, - BreakStatement = 249, - ReturnStatement = 250, - WithStatement = 251, - SwitchStatement = 252, - LabeledStatement = 253, - ThrowStatement = 254, - TryStatement = 255, - DebuggerStatement = 256, - VariableDeclaration = 257, - VariableDeclarationList = 258, - FunctionDeclaration = 259, - ClassDeclaration = 260, - InterfaceDeclaration = 261, - TypeAliasDeclaration = 262, - EnumDeclaration = 263, - ModuleDeclaration = 264, - ModuleBlock = 265, - CaseBlock = 266, - NamespaceExportDeclaration = 267, - ImportEqualsDeclaration = 268, - ImportDeclaration = 269, - ImportClause = 270, - NamespaceImport = 271, - NamedImports = 272, - ImportSpecifier = 273, - ExportAssignment = 274, - ExportDeclaration = 275, - NamedExports = 276, - NamespaceExport = 277, - ExportSpecifier = 278, - MissingDeclaration = 279, - ExternalModuleReference = 280, - JsxElement = 281, - JsxSelfClosingElement = 282, - JsxOpeningElement = 283, - JsxClosingElement = 284, - JsxFragment = 285, - JsxOpeningFragment = 286, - JsxClosingFragment = 287, - JsxAttribute = 288, - JsxAttributes = 289, - JsxSpreadAttribute = 290, - JsxExpression = 291, - CaseClause = 292, - DefaultClause = 293, - HeritageClause = 294, - CatchClause = 295, - AssertClause = 296, - AssertEntry = 297, - ImportTypeAssertionContainer = 298, - PropertyAssignment = 299, - ShorthandPropertyAssignment = 300, - SpreadAssignment = 301, - EnumMember = 302, - UnparsedPrologue = 303, - UnparsedPrepend = 304, - UnparsedText = 305, - UnparsedInternalText = 306, - UnparsedSyntheticReference = 307, - SourceFile = 308, - Bundle = 309, - UnparsedSource = 310, - InputFiles = 311, - JSDocTypeExpression = 312, - JSDocNameReference = 313, - JSDocMemberName = 314, - JSDocAllType = 315, - JSDocUnknownType = 316, - JSDocNullableType = 317, - JSDocNonNullableType = 318, - JSDocOptionalType = 319, - JSDocFunctionType = 320, - JSDocVariadicType = 321, - JSDocNamepathType = 322, - JSDoc = 323, + TupleKeyword = 154, + TypeKeyword = 155, + UndefinedKeyword = 156, + UniqueKeyword = 157, + UnknownKeyword = 158, + FromKeyword = 159, + GlobalKeyword = 160, + BigIntKeyword = 161, + OverrideKeyword = 162, + OfKeyword = 163, + QualifiedName = 164, + ComputedPropertyName = 165, + TypeParameter = 166, + Parameter = 167, + Decorator = 168, + PropertySignature = 169, + PropertyDeclaration = 170, + MethodSignature = 171, + MethodDeclaration = 172, + ClassStaticBlockDeclaration = 173, + Constructor = 174, + GetAccessor = 175, + SetAccessor = 176, + CallSignature = 177, + ConstructSignature = 178, + IndexSignature = 179, + TypePredicate = 180, + TypeReference = 181, + FunctionType = 182, + ConstructorType = 183, + TypeQuery = 184, + TypeLiteral = 185, + ArrayType = 186, + TupleType = 187, + OptionalType = 188, + RestType = 189, + UnionType = 190, + IntersectionType = 191, + ConditionalType = 192, + InferType = 193, + ParenthesizedType = 194, + ThisType = 195, + TypeOperator = 196, + IndexedAccessType = 197, + MappedType = 198, + LiteralType = 199, + NamedTupleMember = 200, + TemplateLiteralType = 201, + TemplateLiteralTypeSpan = 202, + ImportType = 203, + ObjectBindingPattern = 204, + ArrayBindingPattern = 205, + BindingElement = 206, + ArrayLiteralExpression = 207, + ObjectLiteralExpression = 208, + PropertyAccessExpression = 209, + ElementAccessExpression = 210, + CallExpression = 211, + NewExpression = 212, + TaggedTemplateExpression = 213, + TypeAssertionExpression = 214, + ParenthesizedExpression = 215, + FunctionExpression = 216, + ArrowFunction = 217, + DeleteExpression = 218, + TypeOfExpression = 219, + VoidExpression = 220, + AwaitExpression = 221, + PrefixUnaryExpression = 222, + PostfixUnaryExpression = 223, + BinaryExpression = 224, + ConditionalExpression = 225, + TemplateExpression = 226, + YieldExpression = 227, + SpreadElement = 228, + ClassExpression = 229, + OmittedExpression = 230, + ExpressionWithTypeArguments = 231, + AsExpression = 232, + NonNullExpression = 233, + MetaProperty = 234, + SyntheticExpression = 235, + SatisfiesExpression = 236, + TemplateSpan = 237, + SemicolonClassElement = 238, + Block = 239, + EmptyStatement = 240, + VariableStatement = 241, + ExpressionStatement = 242, + IfStatement = 243, + DoStatement = 244, + WhileStatement = 245, + ForStatement = 246, + ForInStatement = 247, + ForOfStatement = 248, + ContinueStatement = 249, + BreakStatement = 250, + ReturnStatement = 251, + WithStatement = 252, + SwitchStatement = 253, + LabeledStatement = 254, + ThrowStatement = 255, + TryStatement = 256, + DebuggerStatement = 257, + VariableDeclaration = 258, + VariableDeclarationList = 259, + FunctionDeclaration = 260, + ClassDeclaration = 261, + InterfaceDeclaration = 262, + TypeAliasDeclaration = 263, + EnumDeclaration = 264, + ModuleDeclaration = 265, + ModuleBlock = 266, + CaseBlock = 267, + NamespaceExportDeclaration = 268, + ImportEqualsDeclaration = 269, + ImportDeclaration = 270, + ImportClause = 271, + NamespaceImport = 272, + NamedImports = 273, + ImportSpecifier = 274, + ExportAssignment = 275, + ExportDeclaration = 276, + NamedExports = 277, + NamespaceExport = 278, + ExportSpecifier = 279, + MissingDeclaration = 280, + ExternalModuleReference = 281, + JsxElement = 282, + JsxSelfClosingElement = 283, + JsxOpeningElement = 284, + JsxClosingElement = 285, + JsxFragment = 286, + JsxOpeningFragment = 287, + JsxClosingFragment = 288, + JsxAttribute = 289, + JsxAttributes = 290, + JsxSpreadAttribute = 291, + JsxExpression = 292, + CaseClause = 293, + DefaultClause = 294, + HeritageClause = 295, + CatchClause = 296, + AssertClause = 297, + AssertEntry = 298, + ImportTypeAssertionContainer = 299, + PropertyAssignment = 300, + ShorthandPropertyAssignment = 301, + SpreadAssignment = 302, + EnumMember = 303, + UnparsedPrologue = 304, + UnparsedPrepend = 305, + UnparsedText = 306, + UnparsedInternalText = 307, + UnparsedSyntheticReference = 308, + SourceFile = 309, + Bundle = 310, + UnparsedSource = 311, + InputFiles = 312, + JSDocTypeExpression = 313, + JSDocNameReference = 314, + JSDocMemberName = 315, + JSDocAllType = 316, + JSDocUnknownType = 317, + JSDocNullableType = 318, + JSDocNonNullableType = 319, + JSDocOptionalType = 320, + JSDocFunctionType = 321, + JSDocVariadicType = 322, + JSDocNamepathType = 323, + JSDoc = 324, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 323, - JSDocText = 324, - JSDocTypeLiteral = 325, - JSDocSignature = 326, - JSDocLink = 327, - JSDocLinkCode = 328, - JSDocLinkPlain = 329, - JSDocTag = 330, - JSDocAugmentsTag = 331, - JSDocImplementsTag = 332, - JSDocAuthorTag = 333, - JSDocDeprecatedTag = 334, - JSDocClassTag = 335, - JSDocPublicTag = 336, - JSDocPrivateTag = 337, - JSDocProtectedTag = 338, - JSDocReadonlyTag = 339, - JSDocOverrideTag = 340, - JSDocCallbackTag = 341, - JSDocEnumTag = 342, - JSDocParameterTag = 343, - JSDocReturnTag = 344, - JSDocThisTag = 345, - JSDocTypeTag = 346, - JSDocTemplateTag = 347, - JSDocTypedefTag = 348, - JSDocSeeTag = 349, - JSDocPropertyTag = 350, - SyntaxList = 351, - NotEmittedStatement = 352, - PartiallyEmittedExpression = 353, - CommaListExpression = 354, - MergeDeclarationMarker = 355, - EndOfDeclarationMarker = 356, - SyntheticReferenceExpression = 357, - Count = 358, + JSDocComment = 324, + JSDocText = 325, + JSDocTypeLiteral = 326, + JSDocSignature = 327, + JSDocLink = 328, + JSDocLinkCode = 329, + JSDocLinkPlain = 330, + JSDocTag = 331, + JSDocAugmentsTag = 332, + JSDocImplementsTag = 333, + JSDocAuthorTag = 334, + JSDocDeprecatedTag = 335, + JSDocClassTag = 336, + JSDocPublicTag = 337, + JSDocPrivateTag = 338, + JSDocProtectedTag = 339, + JSDocReadonlyTag = 340, + JSDocOverrideTag = 341, + JSDocCallbackTag = 342, + JSDocEnumTag = 343, + JSDocParameterTag = 344, + JSDocReturnTag = 345, + JSDocThisTag = 346, + JSDocTypeTag = 347, + JSDocTemplateTag = 348, + JSDocTypedefTag = 349, + JSDocSeeTag = 350, + JSDocPropertyTag = 351, + SyntaxList = 352, + NotEmittedStatement = 353, + PartiallyEmittedExpression = 354, + CommaListExpression = 355, + MergeDeclarationMarker = 356, + EndOfDeclarationMarker = 357, + SyntheticReferenceExpression = 358, + Count = 359, FirstAssignment = 63, LastAssignment = 78, FirstCompoundAssignment = 64, @@ -487,15 +488,15 @@ declare namespace ts { FirstReservedWord = 81, LastReservedWord = 116, FirstKeyword = 81, - LastKeyword = 162, + LastKeyword = 163, FirstFutureReservedWord = 117, LastFutureReservedWord = 125, - FirstTypeNode = 179, - LastTypeNode = 202, + FirstTypeNode = 180, + LastTypeNode = 203, FirstPunctuation = 18, LastPunctuation = 78, FirstToken = 0, - LastToken = 162, + LastToken = 163, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -504,19 +505,19 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 78, - FirstStatement = 240, - LastStatement = 256, - FirstNode = 163, - FirstJSDocNode = 312, - LastJSDocNode = 350, - FirstJSDocTagNode = 330, - LastJSDocTagNode = 350 + FirstStatement = 241, + LastStatement = 257, + FirstNode = 164, + FirstJSDocNode = 313, + LastJSDocNode = 351, + FirstJSDocTagNode = 331, + LastJSDocTagNode = 351 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TupleKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; @@ -4810,6 +4811,8 @@ declare namespace ts { function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain | NonNullChain; function isNullishCoalesce(node: Node): boolean; function isConstTypeReference(node: Node): boolean; + function isTupleTypeReference(node: Node): boolean; + function isConstOrTupleTypeReference(node: Node): boolean; function skipPartiallyEmittedExpressions(node: Expression): Expression; function skipPartiallyEmittedExpressions(node: Node): Node; function isNonNullChain(node: Node): node is NonNullChain; diff --git a/tests/baselines/reference/quickInfoForTupleAssertions.baseline b/tests/baselines/reference/quickInfoForTupleAssertions.baseline new file mode 100644 index 0000000000000..f30efb38ad133 --- /dev/null +++ b/tests/baselines/reference/quickInfoForTupleAssertions.baseline @@ -0,0 +1,170 @@ +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoForTupleAssertions.ts", + "position": 6, + "name": "1" + }, + "quickInfo": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 6, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [] + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoForTupleAssertions.ts", + "position": 33, + "name": "2" + }, + "quickInfo": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 33, + "length": 5 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tuple", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [] + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/tupleAssertions.errors.txt b/tests/baselines/reference/tupleAssertions.errors.txt new file mode 100644 index 0000000000000..42e34c5a42c6a --- /dev/null +++ b/tests/baselines/reference/tupleAssertions.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(11,10): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(12,10): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(13,10): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(14,10): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(16,10): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(17,10): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(21,18): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(22,18): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(23,18): error TS1484: A 'tuple' assertions can only be applied to array literals. +tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts(25,18): error TS1484: A 'tuple' assertions can only be applied to array literals. + + +==== tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts (10 errors) ==== + let a1 = [] as tuple; + let a2 = [1, 2, 3] as tuple; + let a3 = [10, 'hello', true] as tuple; + let a4 = [...[1, 2, 3]] as tuple; + let a5 = [1, 2, 3]; + let a6 = [...a5] as tuple; + let a7 = [...a6]; + let a8 = ['abc', ...a7] as tuple; + let a9 = [...a8]; + + let e1 = 'abc' as tuple; + ~~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let e2 = 10 as tuple; + ~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let e3 = { x: 10, y: 20 } as tuple; + ~~~~~~~~~~~~~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let e4 = `${e1}-${e2}` as tuple; + ~~~~~~~~~~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + + let p1 = (10) as tuple; // Error + ~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let p2 = ((-10)) as tuple; // Error + ~~~~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let p3 = ([(10)]) as tuple; // OK + let p4 = [[[[10]]]] as tuple; // OK + + let q1 = 10; // Error + ~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let q2 = 'abc'; // Error + ~~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let q3 = true; // Error + ~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + let q4 = [1, 2, 3]; // OK + let q5 = { x: 10, y: 20 }; // Error + ~~~~~~~~~~~~~~~~ +!!! error TS1484: A 'tuple' assertions can only be applied to array literals. + + function accessorNames(propName: S) { + return [`get-${propName}`, `set-${propName}`] as tuple; + } + + const ns1 = accessorNames('foo'); \ No newline at end of file diff --git a/tests/baselines/reference/tupleAssertions.js b/tests/baselines/reference/tupleAssertions.js new file mode 100644 index 0000000000000..f55a3c1575522 --- /dev/null +++ b/tests/baselines/reference/tupleAssertions.js @@ -0,0 +1,94 @@ +//// [tupleAssertions.ts] +let a1 = [] as tuple; +let a2 = [1, 2, 3] as tuple; +let a3 = [10, 'hello', true] as tuple; +let a4 = [...[1, 2, 3]] as tuple; +let a5 = [1, 2, 3]; +let a6 = [...a5] as tuple; +let a7 = [...a6]; +let a8 = ['abc', ...a7] as tuple; +let a9 = [...a8]; + +let e1 = 'abc' as tuple; +let e2 = 10 as tuple; +let e3 = { x: 10, y: 20 } as tuple; +let e4 = `${e1}-${e2}` as tuple; + +let p1 = (10) as tuple; // Error +let p2 = ((-10)) as tuple; // Error +let p3 = ([(10)]) as tuple; // OK +let p4 = [[[[10]]]] as tuple; // OK + +let q1 = 10; // Error +let q2 = 'abc'; // Error +let q3 = true; // Error +let q4 = [1, 2, 3]; // OK +let q5 = { x: 10, y: 20 }; // Error + +function accessorNames(propName: S) { + return [`get-${propName}`, `set-${propName}`] as tuple; +} + +const ns1 = accessorNames('foo'); + +//// [tupleAssertions.js] +"use strict"; +let a1 = []; +let a2 = [1, 2, 3]; +let a3 = [10, 'hello', true]; +let a4 = [...[1, 2, 3]]; +let a5 = [1, 2, 3]; +let a6 = [...a5]; +let a7 = [...a6]; +let a8 = ['abc', ...a7]; +let a9 = [...a8]; +let e1 = 'abc'; +let e2 = 10; +let e3 = { x: 10, y: 20 }; +let e4 = `${e1}-${e2}`; +let p1 = (10); // Error +let p2 = ((-10)); // Error +let p3 = ([(10)]); // OK +let p4 = [[[[10]]]]; // OK +let q1 = 10; // Error +let q2 = 'abc'; // Error +let q3 = true; // Error +let q4 = [1, 2, 3]; // OK +let q5 = { x: 10, y: 20 }; // Error +function accessorNames(propName) { + return [`get-${propName}`, `set-${propName}`]; +} +const ns1 = accessorNames('foo'); + + +//// [tupleAssertions.d.ts] +declare let a1: []; +declare let a2: [number, number, number]; +declare let a3: [number, string, boolean]; +declare let a4: [number, number, number]; +declare let a5: number[]; +declare let a6: number[]; +declare let a7: number[]; +declare let a8: [string, ...number[]]; +declare let a9: (string | number)[]; +declare let e1: "abc"; +declare let e2: 10; +declare let e3: { + x: number; + y: number; +}; +declare let e4: string; +declare let p1: 10; +declare let p2: -10; +declare let p3: number[]; +declare let p4: [[[[number]]]]; +declare let q1: 10; +declare let q2: "abc"; +declare let q3: true; +declare let q4: [number, number, number]; +declare let q5: { + x: number; + y: number; +}; +declare function accessorNames(propName: S): [string, string]; +declare const ns1: [string, string]; diff --git a/tests/baselines/reference/tupleAssertions.symbols b/tests/baselines/reference/tupleAssertions.symbols new file mode 100644 index 0000000000000..a1b2e57a28ee2 --- /dev/null +++ b/tests/baselines/reference/tupleAssertions.symbols @@ -0,0 +1,112 @@ +=== tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts === +let a1 = [] as tuple; +>a1 : Symbol(a1, Decl(tupleAssertions.ts, 0, 3)) +>tuple : Symbol(tuple) + +let a2 = [1, 2, 3] as tuple; +>a2 : Symbol(a2, Decl(tupleAssertions.ts, 1, 3)) +>tuple : Symbol(tuple) + +let a3 = [10, 'hello', true] as tuple; +>a3 : Symbol(a3, Decl(tupleAssertions.ts, 2, 3)) +>tuple : Symbol(tuple) + +let a4 = [...[1, 2, 3]] as tuple; +>a4 : Symbol(a4, Decl(tupleAssertions.ts, 3, 3)) +>tuple : Symbol(tuple) + +let a5 = [1, 2, 3]; +>a5 : Symbol(a5, Decl(tupleAssertions.ts, 4, 3)) + +let a6 = [...a5] as tuple; +>a6 : Symbol(a6, Decl(tupleAssertions.ts, 5, 3)) +>a5 : Symbol(a5, Decl(tupleAssertions.ts, 4, 3)) +>tuple : Symbol(tuple) + +let a7 = [...a6]; +>a7 : Symbol(a7, Decl(tupleAssertions.ts, 6, 3)) +>a6 : Symbol(a6, Decl(tupleAssertions.ts, 5, 3)) + +let a8 = ['abc', ...a7] as tuple; +>a8 : Symbol(a8, Decl(tupleAssertions.ts, 7, 3)) +>a7 : Symbol(a7, Decl(tupleAssertions.ts, 6, 3)) +>tuple : Symbol(tuple) + +let a9 = [...a8]; +>a9 : Symbol(a9, Decl(tupleAssertions.ts, 8, 3)) +>a8 : Symbol(a8, Decl(tupleAssertions.ts, 7, 3)) + +let e1 = 'abc' as tuple; +>e1 : Symbol(e1, Decl(tupleAssertions.ts, 10, 3)) +>tuple : Symbol(tuple) + +let e2 = 10 as tuple; +>e2 : Symbol(e2, Decl(tupleAssertions.ts, 11, 3)) +>tuple : Symbol(tuple) + +let e3 = { x: 10, y: 20 } as tuple; +>e3 : Symbol(e3, Decl(tupleAssertions.ts, 12, 3)) +>x : Symbol(x, Decl(tupleAssertions.ts, 12, 10)) +>y : Symbol(y, Decl(tupleAssertions.ts, 12, 17)) +>tuple : Symbol(tuple) + +let e4 = `${e1}-${e2}` as tuple; +>e4 : Symbol(e4, Decl(tupleAssertions.ts, 13, 3)) +>e1 : Symbol(e1, Decl(tupleAssertions.ts, 10, 3)) +>e2 : Symbol(e2, Decl(tupleAssertions.ts, 11, 3)) +>tuple : Symbol(tuple) + +let p1 = (10) as tuple; // Error +>p1 : Symbol(p1, Decl(tupleAssertions.ts, 15, 3)) +>tuple : Symbol(tuple) + +let p2 = ((-10)) as tuple; // Error +>p2 : Symbol(p2, Decl(tupleAssertions.ts, 16, 3)) +>tuple : Symbol(tuple) + +let p3 = ([(10)]) as tuple; // OK +>p3 : Symbol(p3, Decl(tupleAssertions.ts, 17, 3)) +>tuple : Symbol(tuple) + +let p4 = [[[[10]]]] as tuple; // OK +>p4 : Symbol(p4, Decl(tupleAssertions.ts, 18, 3)) +>tuple : Symbol(tuple) + +let q1 = 10; // Error +>q1 : Symbol(q1, Decl(tupleAssertions.ts, 20, 3)) +>tuple : Symbol(tuple) + +let q2 = 'abc'; // Error +>q2 : Symbol(q2, Decl(tupleAssertions.ts, 21, 3)) +>tuple : Symbol(tuple) + +let q3 = true; // Error +>q3 : Symbol(q3, Decl(tupleAssertions.ts, 22, 3)) +>tuple : Symbol(tuple) + +let q4 = [1, 2, 3]; // OK +>q4 : Symbol(q4, Decl(tupleAssertions.ts, 23, 3)) +>tuple : Symbol(tuple) + +let q5 = { x: 10, y: 20 }; // Error +>q5 : Symbol(q5, Decl(tupleAssertions.ts, 24, 3)) +>tuple : Symbol(tuple) +>x : Symbol(x, Decl(tupleAssertions.ts, 24, 18)) +>y : Symbol(y, Decl(tupleAssertions.ts, 24, 25)) + +function accessorNames(propName: S) { +>accessorNames : Symbol(accessorNames, Decl(tupleAssertions.ts, 24, 34)) +>S : Symbol(S, Decl(tupleAssertions.ts, 26, 23)) +>propName : Symbol(propName, Decl(tupleAssertions.ts, 26, 41)) +>S : Symbol(S, Decl(tupleAssertions.ts, 26, 23)) + + return [`get-${propName}`, `set-${propName}`] as tuple; +>propName : Symbol(propName, Decl(tupleAssertions.ts, 26, 41)) +>propName : Symbol(propName, Decl(tupleAssertions.ts, 26, 41)) +>tuple : Symbol(tuple) +} + +const ns1 = accessorNames('foo'); +>ns1 : Symbol(ns1, Decl(tupleAssertions.ts, 30, 5)) +>accessorNames : Symbol(accessorNames, Decl(tupleAssertions.ts, 24, 34)) + diff --git a/tests/baselines/reference/tupleAssertions.types b/tests/baselines/reference/tupleAssertions.types new file mode 100644 index 0000000000000..49734065b34d3 --- /dev/null +++ b/tests/baselines/reference/tupleAssertions.types @@ -0,0 +1,174 @@ +=== tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts === +let a1 = [] as tuple; +>a1 : [] +>[] as tuple : [] +>[] : never[] + +let a2 = [1, 2, 3] as tuple; +>a2 : [number, number, number] +>[1, 2, 3] as tuple : [number, number, number] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +let a3 = [10, 'hello', true] as tuple; +>a3 : [number, string, boolean] +>[10, 'hello', true] as tuple : [number, string, boolean] +>[10, 'hello', true] : (string | number | boolean)[] +>10 : 10 +>'hello' : "hello" +>true : true + +let a4 = [...[1, 2, 3]] as tuple; +>a4 : [number, number, number] +>[...[1, 2, 3]] as tuple : [number, number, number] +>[...[1, 2, 3]] : number[] +>...[1, 2, 3] : number +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +let a5 = [1, 2, 3]; +>a5 : number[] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +let a6 = [...a5] as tuple; +>a6 : number[] +>[...a5] as tuple : number[] +>[...a5] : number[] +>...a5 : number +>a5 : number[] + +let a7 = [...a6]; +>a7 : number[] +>[...a6] : number[] +>...a6 : number +>a6 : number[] + +let a8 = ['abc', ...a7] as tuple; +>a8 : [string, ...number[]] +>['abc', ...a7] as tuple : [string, ...number[]] +>['abc', ...a7] : (string | number)[] +>'abc' : "abc" +>...a7 : number +>a7 : number[] + +let a9 = [...a8]; +>a9 : (string | number)[] +>[...a8] : (string | number)[] +>...a8 : string | number +>a8 : [string, ...number[]] + +let e1 = 'abc' as tuple; +>e1 : "abc" +>'abc' as tuple : "abc" +>'abc' : "abc" + +let e2 = 10 as tuple; +>e2 : 10 +>10 as tuple : 10 +>10 : 10 + +let e3 = { x: 10, y: 20 } as tuple; +>e3 : { x: number; y: number; } +>{ x: 10, y: 20 } as tuple : { x: number; y: number; } +>{ x: 10, y: 20 } : { x: number; y: number; } +>x : number +>10 : 10 +>y : number +>20 : 20 + +let e4 = `${e1}-${e2}` as tuple; +>e4 : string +>`${e1}-${e2}` as tuple : string +>`${e1}-${e2}` : string +>e1 : "abc" +>e2 : 10 + +let p1 = (10) as tuple; // Error +>p1 : 10 +>(10) as tuple : 10 +>(10) : 10 +>10 : 10 + +let p2 = ((-10)) as tuple; // Error +>p2 : -10 +>((-10)) as tuple : -10 +>((-10)) : -10 +>(-10) : -10 +>-10 : -10 +>10 : 10 + +let p3 = ([(10)]) as tuple; // OK +>p3 : number[] +>([(10)]) as tuple : number[] +>([(10)]) : number[] +>[(10)] : number[] +>(10) : 10 +>10 : 10 + +let p4 = [[[[10]]]] as tuple; // OK +>p4 : [[[[number]]]] +>[[[[10]]]] as tuple : [[[[number]]]] +>[[[[10]]]] : number[][][][] +>[[[10]]] : number[][][] +>[[10]] : number[][] +>[10] : number[] +>10 : 10 + +let q1 = 10; // Error +>q1 : 10 +> 10 : 10 +>10 : 10 + +let q2 = 'abc'; // Error +>q2 : "abc" +> 'abc' : "abc" +>'abc' : "abc" + +let q3 = true; // Error +>q3 : true +> true : true +>true : true + +let q4 = [1, 2, 3]; // OK +>q4 : [number, number, number] +> [1, 2, 3] : [number, number, number] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +let q5 = { x: 10, y: 20 }; // Error +>q5 : { x: number; y: number; } +> { x: 10, y: 20 } : { x: number; y: number; } +>{ x: 10, y: 20 } : { x: number; y: number; } +>x : number +>10 : 10 +>y : number +>20 : 20 + +function accessorNames(propName: S) { +>accessorNames : (propName: S) => [string, string] +>propName : S + + return [`get-${propName}`, `set-${propName}`] as tuple; +>[`get-${propName}`, `set-${propName}`] as tuple : [string, string] +>[`get-${propName}`, `set-${propName}`] : string[] +>`get-${propName}` : string +>propName : S +>`set-${propName}` : string +>propName : S +} + +const ns1 = accessorNames('foo'); +>ns1 : [string, string] +>accessorNames('foo') : [string, string] +>accessorNames : (propName: S) => [string, string] +>'foo' : "foo" + diff --git a/tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts b/tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts new file mode 100644 index 0000000000000..c4a35e8101721 --- /dev/null +++ b/tests/cases/conformance/expressions/typeAssertions/tupleAssertions.ts @@ -0,0 +1,35 @@ +// @strict: true +// @declaration: true +// @target: esnext + +let a1 = [] as tuple; +let a2 = [1, 2, 3] as tuple; +let a3 = [10, 'hello', true] as tuple; +let a4 = [...[1, 2, 3]] as tuple; +let a5 = [1, 2, 3]; +let a6 = [...a5] as tuple; +let a7 = [...a6]; +let a8 = ['abc', ...a7] as tuple; +let a9 = [...a8]; + +let e1 = 'abc' as tuple; +let e2 = 10 as tuple; +let e3 = { x: 10, y: 20 } as tuple; +let e4 = `${e1}-${e2}` as tuple; + +let p1 = (10) as tuple; // Error +let p2 = ((-10)) as tuple; // Error +let p3 = ([(10)]) as tuple; // OK +let p4 = [[[[10]]]] as tuple; // OK + +let q1 = 10; // Error +let q2 = 'abc'; // Error +let q3 = true; // Error +let q4 = [1, 2, 3]; // OK +let q5 = { x: 10, y: 20 }; // Error + +function accessorNames(propName: S) { + return [`get-${propName}`, `set-${propName}`] as tuple; +} + +const ns1 = accessorNames('foo'); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoForTupleAssertions.ts b/tests/cases/fourslash/quickInfoForTupleAssertions.ts new file mode 100644 index 0000000000000..8149e07f9a337 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForTupleAssertions.ts @@ -0,0 +1,5 @@ +/// + +////const /*1*/a = ["foo", [42], true] as /*2*/tuple; + +verify.baselineQuickInfo(); diff --git a/tests/cases/fourslash/semanticClassificationTupleAssertion.ts b/tests/cases/fourslash/semanticClassificationTupleAssertion.ts new file mode 100644 index 0000000000000..e9e3b03ca21d4 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationTupleAssertion.ts @@ -0,0 +1,22 @@ +/// + +////[] as tuple; + +const c1 = classification("original"); +verify.syntacticClassificationsAre( + c1.punctuation("["), + c1.punctuation("]"), + c1.keyword("as"), + c1.keyword("tuple"), + c1.punctuation(";") +); + + +const c2 = classification("2020"); +verify.syntacticClassificationsAre( + c2.semanticToken("punctuation", "["), + c2.semanticToken("punctuation", "]"), + c2.semanticToken("keyword", "as"), + c2.semanticToken("keyword", "tuple"), + c2.semanticToken("punctuation", ";") +);