From 80ce1df93495d75f4fcb46ab9658f1cafe0ed52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 14 Jan 2023 09:24:58 +0100 Subject: [PATCH 1/2] Allow `preferinfer` modifier on type parameters --- src/compiler/factory/nodeFactory.ts | 2 ++ src/compiler/program.ts | 1 + src/compiler/scanner.ts | 1 + src/compiler/transformers/ts.ts | 1 + src/compiler/types.ts | 10 ++++++++-- src/compiler/utilities.ts | 1 + src/compiler/utilitiesPublic.ts | 1 + 7 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 739d47e707a91..8015778c3ba25 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -1331,6 +1331,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode case SyntaxKind.InKeyword: case SyntaxKind.OutKeyword: case SyntaxKind.OverrideKeyword: + case SyntaxKind.PreferInferKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: @@ -1417,6 +1418,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode if (flags & ModifierFlags.Async) result.push(createModifier(SyntaxKind.AsyncKeyword)); if (flags & ModifierFlags.In) result.push(createModifier(SyntaxKind.InKeyword)); if (flags & ModifierFlags.Out) result.push(createModifier(SyntaxKind.OutKeyword)); + if (flags & ModifierFlags.PreferInfer) result.push(createModifier(SyntaxKind.PreferInferKeyword)); return result.length ? result : undefined; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 67e7e20928d58..b96a956e8616b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3016,6 +3016,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg case SyntaxKind.OverrideKeyword: case SyntaxKind.InKeyword: case SyntaxKind.OutKeyword: + case SyntaxKind.PreferInferKeyword: diagnostics.push(createDiagnosticForNode(modifier, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, tokenToString(modifier.kind))); break; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index db14e8710fa87..99236146db403 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -156,6 +156,7 @@ export const textToKeywordObj: MapLike = { number: SyntaxKind.NumberKeyword, object: SyntaxKind.ObjectKeyword, package: SyntaxKind.PackageKeyword, + preferinfer: SyntaxKind.PreferInferKeyword, private: SyntaxKind.PrivateKeyword, protected: SyntaxKind.ProtectedKeyword, public: SyntaxKind.PublicKeyword, diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 1b27a345ce67b..4b034987eedaf 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -602,6 +602,7 @@ export function transformTypeScript(context: TransformationContext) { case SyntaxKind.ReadonlyKeyword: case SyntaxKind.InKeyword: case SyntaxKind.OutKeyword: + case SyntaxKind.PreferInferKeyword: // TypeScript accessibility and readonly modifiers are elided // falls through case SyntaxKind.ArrayType: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 80f0c539aef82..1069df9fcb390 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -198,6 +198,7 @@ export const enum SyntaxKind { NamespaceKeyword, NeverKeyword, OutKeyword, + PreferInferKeyword, ReadonlyKeyword, RequireKeyword, NumberKeyword, @@ -625,6 +626,7 @@ export type KeywordSyntaxKind = | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword + | SyntaxKind.PreferInferKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword @@ -665,6 +667,7 @@ export type ModifierSyntaxKind = | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword + | SyntaxKind.PreferInferKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword @@ -858,6 +861,7 @@ export const enum ModifierFlags { In = 1 << 15, // Contravariance modifier Out = 1 << 16, // Covariance modifier Decorator = 1 << 17, // Contains a decorator. + PreferInfer = 1 << 18, // preferinfer modifier on type params to allow partial inference HasComputedFlags = 1 << 29, // Modifier flags have been computed AccessibilityModifier = Public | Private | Protected, @@ -865,9 +869,9 @@ export const enum ModifierFlags { ParameterPropertyModifier = AccessibilityModifier | Readonly | Override, NonPublicAccessibilityModifier = Private | Protected, - TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override | In | Out, + TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override | In | Out | PreferInfer, ExportDefault = Export | Default, - All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Accessor | Async | Default | Const | Deprecated | Override | In | Out | Decorator, + All = ExportDefault | Static | Accessor | Async | Deprecated | Decorator | TypeScriptModifier, Modifier = All & ~Decorator } @@ -1606,6 +1610,7 @@ export type DeclareKeyword = ModifierToken; export type DefaultKeyword = ModifierToken; export type ExportKeyword = ModifierToken; export type InKeyword = ModifierToken; +export type PreferInferKeyword = ModifierToken; export type PrivateKeyword = ModifierToken; export type ProtectedKeyword = ModifierToken; export type PublicKeyword = ModifierToken; @@ -1626,6 +1631,7 @@ export type Modifier = | DefaultKeyword | ExportKeyword | InKeyword + | PreferInferKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index cc95054826c47..571ae39822fc0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6238,6 +6238,7 @@ export function modifierToFlag(token: SyntaxKind): ModifierFlags { case SyntaxKind.OverrideKeyword: return ModifierFlags.Override; case SyntaxKind.InKeyword: return ModifierFlags.In; case SyntaxKind.OutKeyword: return ModifierFlags.Out; + case SyntaxKind.PreferInferKeyword: return ModifierFlags.PreferInfer; case SyntaxKind.Decorator: return ModifierFlags.Decorator; } return ModifierFlags.None; diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 2e78151cda548..0114f6075fbf9 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1523,6 +1523,7 @@ export function isModifierKind(token: SyntaxKind): token is Modifier["kind"] { case SyntaxKind.ExportKeyword: case SyntaxKind.InKeyword: case SyntaxKind.PublicKeyword: + case SyntaxKind.PreferInferKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.ReadonlyKeyword: From 6901b0a594378ecc340e582510fbb9a4569335ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 14 Jan 2023 09:29:52 +0100 Subject: [PATCH 2/2] Allow for partial inference by fixing inferences for type parameters preferring inferring Co-authored-by: Wesley Wigham --- src/compiler/checker.ts | 55 +- .../reference/api/tsserverlibrary.d.ts | 469 +++++++++--------- tests/baselines/reference/api/typescript.d.ts | 469 +++++++++--------- .../reference/inferPartialTypeArguments.js | 145 ++++++ .../inferPartialTypeArguments.symbols | 205 ++++++++ .../reference/inferPartialTypeArguments.types | 182 +++++++ ...inferPartialTypeArgumentsErrors.errors.txt | 55 ++ .../inferPartialTypeArgumentsErrors.js | 134 +++++ .../inferPartialTypeArgumentsErrors.symbols | 172 +++++++ .../inferPartialTypeArgumentsErrors.types | 163 ++++++ .../inferPartialTypeArguments.tsx | 57 +++ .../inferPartialTypeArgumentsErrors.ts | 42 ++ 12 files changed, 1676 insertions(+), 472 deletions(-) create mode 100644 tests/baselines/reference/inferPartialTypeArguments.js create mode 100644 tests/baselines/reference/inferPartialTypeArguments.symbols create mode 100644 tests/baselines/reference/inferPartialTypeArguments.types create mode 100644 tests/baselines/reference/inferPartialTypeArgumentsErrors.errors.txt create mode 100644 tests/baselines/reference/inferPartialTypeArgumentsErrors.js create mode 100644 tests/baselines/reference/inferPartialTypeArgumentsErrors.symbols create mode 100644 tests/baselines/reference/inferPartialTypeArgumentsErrors.types create mode 100644 tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArguments.tsx create mode 100644 tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3f4d60657e404..259e5a4a7f239 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1940,6 +1940,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const markerSubTypeForCheck = createTypeParameter(); markerSubTypeForCheck.constraint = markerSuperTypeForCheck; + const preferInferType = createTypeParameter(); + const noTypePredicate = createTypePredicate(TypePredicateKind.Identifier, "<>", 0, anyType); const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, SignatureFlags.None); @@ -13260,6 +13262,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { type.flags & TypeFlags.IndexedAccess && isConstTypeVariable((type as IndexedAccessType).objectType)); } + function isTypeVariablePreferringInference(typeParameter: TypeParameter): boolean { + return some(typeParameter.symbol?.declarations, d => hasSyntacticModifier(d, ModifierFlags.PreferInfer)); + } + function getConstraintOfIndexedAccess(type: IndexedAccessType) { return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined; } @@ -14095,7 +14101,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let minTypeArgumentCount = 0; if (typeParameters) { for (let i = 0; i < typeParameters.length; i++) { - if (!hasTypeParameterDefault(typeParameters[i])) { + if (!hasTypeParameterDefault(typeParameters[i]) && !isTypeVariablePreferringInference(typeParameters[i])) { minTypeArgumentCount = i + 1; } } @@ -14127,7 +14133,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny); for (let i = numTypeArguments; i < numTypeParameters; i++) { - let defaultType = getDefaultFromTypeParameter(typeParameters![i]); + const typeParam = typeParameters![i]; + if (isTypeVariablePreferringInference(typeParam)) { + result[i] = preferInferType; + continue; + } + let defaultType = getDefaultFromTypeParameter(typeParam); if (isJavaScriptImplicitAny && defaultType && (isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType))) { defaultType = anyType; } @@ -31865,9 +31876,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function checkTypeArguments(signature: Signature, typeArgumentNodes: readonly TypeNode[], reportErrors: boolean, headMessage?: DiagnosticMessage): Type[] | undefined { + return checkTypeArgumentsTypes(signature, typeArgumentNodes, map(typeArgumentNodes, getTypeFromTypeNode), reportErrors, headMessage); + } + + function checkTypeArgumentsTypes(signature: Signature, typeArgumentNodes: readonly TypeNode[], typeArguments: readonly Type[], reportErrors: boolean, headMessage?: DiagnosticMessage): Type[] | undefined { const isJavascript = isInJSFile(signature.declaration); const typeParameters = signature.typeParameters!; - const typeArgumentTypes = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript); + const typeArgumentTypes = fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript); + if (some(typeArgumentTypes, t => t === preferInferType)) { + // Do validation once partial inference is complete + return typeArgumentTypes; + } let mapper: TypeMapper | undefined; for (let i = 0; i < typeArgumentNodes.length; i++) { Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments"); @@ -32608,6 +32627,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let inferenceContext: InferenceContext | undefined; if (candidate.typeParameters) { + const isJavascript = isInJSFile(candidate.declaration); let typeArgumentTypes: Type[] | undefined; if (some(typeArguments)) { typeArgumentTypes = checkTypeArguments(candidate, typeArguments, /*reportErrors*/ false); @@ -32615,13 +32635,35 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { candidateForTypeArgumentError = candidate; continue; } + if (some(typeArgumentTypes, t => t === preferInferType)) { + // There are implied inferences we must make, despite having type arguments + const originalParams = candidate.typeParameters; + const withOriginalArgs = map(typeArgumentTypes, (r, i) => r === preferInferType ? originalParams[i] : r); + const uninferedInstantiation = getSignatureInstantiation(candidate, withOriginalArgs, isJavascript); + inferenceContext = createInferenceContext(originalParams, uninferedInstantiation, isInJSFile(node) ? InferenceFlags.AnyDefault : InferenceFlags.None); + for (let i = 0; i < inferenceContext.inferences.length; i++) { + const correspondingArgument = typeArgumentTypes[i]; + if (correspondingArgument !== preferInferType) { + const inference = inferenceContext.inferences[i]; + inference.inferredType = correspondingArgument; + inference.isFixed = true; + inference.priority = InferencePriority.None; + } + } + typeArgumentTypes = inferTypeArguments(node, uninferedInstantiation, args, argCheckMode | CheckMode.SkipGenericFunctions, inferenceContext); + // TODO: implement plumbing for error reporting + // if (!checkTypeArgumentsTypes(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) { + // continue; + // } + argCheckMode |= inferenceContext.flags & InferenceFlags.SkippedGenericFunction ? CheckMode.SkipGenericFunctions : CheckMode.Normal; + } } else { inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ isInJSFile(node) ? InferenceFlags.AnyDefault : InferenceFlags.None); typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | CheckMode.SkipGenericFunctions, inferenceContext); argCheckMode |= inferenceContext.flags & InferenceFlags.SkippedGenericFunction ? CheckMode.SkipGenericFunctions : CheckMode.Normal; } - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript, inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a // signature with different arity and we need to perform another arity check. if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { @@ -45649,15 +45691,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_index_signature, tokenToString(modifier.kind)); } } - if (modifier.kind !== SyntaxKind.InKeyword && modifier.kind !== SyntaxKind.OutKeyword && modifier.kind !== SyntaxKind.ConstKeyword) { + if (modifier.kind !== SyntaxKind.InKeyword && modifier.kind !== SyntaxKind.OutKeyword && modifier.kind !== SyntaxKind.ConstKeyword && modifier.kind !== SyntaxKind.PreferInferKeyword) { if (node.kind === SyntaxKind.TypeParameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, tokenToString(modifier.kind)); } } switch (modifier.kind) { case SyntaxKind.ConstKeyword: + case SyntaxKind.PreferInferKeyword: if (node.kind !== SyntaxKind.EnumDeclaration && node.kind !== SyntaxKind.TypeParameter) { - return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(SyntaxKind.ConstKeyword)); + return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(modifier.kind)); } const parent = node.parent; if (node.kind === SyntaxKind.TypeParameter && !(isFunctionLikeDeclaration(parent) || isClassLike(parent) || isFunctionTypeNode(parent) || diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 63c9dfc79ae68..eab225a05d12d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4126,223 +4126,224 @@ declare namespace ts { NamespaceKeyword = 143, NeverKeyword = 144, OutKeyword = 145, - ReadonlyKeyword = 146, - RequireKeyword = 147, - NumberKeyword = 148, - ObjectKeyword = 149, - SatisfiesKeyword = 150, - 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, + PreferInferKeyword = 146, + ReadonlyKeyword = 147, + RequireKeyword = 148, + NumberKeyword = 149, + ObjectKeyword = 150, + SatisfiesKeyword = 151, + SetKeyword = 152, + StringKeyword = 153, + SymbolKeyword = 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, - JSDocOverloadTag = 342, - JSDocEnumTag = 343, - JSDocParameterTag = 344, - JSDocReturnTag = 345, - JSDocThisTag = 346, - JSDocTypeTag = 347, - JSDocTemplateTag = 348, - JSDocTypedefTag = 349, - JSDocSeeTag = 350, - JSDocPropertyTag = 351, - JSDocThrowsTag = 352, - SyntaxList = 353, - NotEmittedStatement = 354, - PartiallyEmittedExpression = 355, - CommaListExpression = 356, - MergeDeclarationMarker = 357, - EndOfDeclarationMarker = 358, - SyntheticReferenceExpression = 359, - Count = 360, + 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, + JSDocOverloadTag = 343, + JSDocEnumTag = 344, + JSDocParameterTag = 345, + JSDocReturnTag = 346, + JSDocThisTag = 347, + JSDocTypeTag = 348, + JSDocTemplateTag = 349, + JSDocTypedefTag = 350, + JSDocSeeTag = 351, + JSDocPropertyTag = 352, + JSDocThrowsTag = 353, + SyntaxList = 354, + NotEmittedStatement = 355, + PartiallyEmittedExpression = 356, + CommaListExpression = 357, + MergeDeclarationMarker = 358, + EndOfDeclarationMarker = 359, + SyntheticReferenceExpression = 360, + Count = 361, FirstAssignment = 63, LastAssignment = 78, FirstCompoundAssignment = 64, @@ -4350,15 +4351,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, @@ -4367,20 +4368,20 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 78, - FirstStatement = 240, - LastStatement = 256, - FirstNode = 163, - FirstJSDocNode = 312, - LastJSDocNode = 352, - FirstJSDocTagNode = 330, - LastJSDocTagNode = 352 + FirstStatement = 241, + LastStatement = 257, + FirstNode = 164, + FirstJSDocNode = 313, + LastJSDocNode = 353, + FirstJSDocTagNode = 331, + LastJSDocTagNode = 353 } 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 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 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.PreferInferKeyword | 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 ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PreferInferKeyword | 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; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; @@ -4436,14 +4437,15 @@ declare namespace ts { In = 32768, Out = 65536, Decorator = 131072, + PreferInfer = 262144, HasComputedFlags = 536870912, AccessibilityModifier = 28, ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, - TypeScriptModifier = 117086, + TypeScriptModifier = 379230, ExportDefault = 1025, - All = 258047, - Modifier = 126975 + All = 520191, + Modifier = 389119 } enum JsxFlags { None = 0, @@ -4555,6 +4557,7 @@ declare namespace ts { type DefaultKeyword = ModifierToken; type ExportKeyword = ModifierToken; type InKeyword = ModifierToken; + type PreferInferKeyword = ModifierToken; type PrivateKeyword = ModifierToken; type ProtectedKeyword = ModifierToken; type PublicKeyword = ModifierToken; @@ -4564,7 +4567,7 @@ declare namespace ts { type StaticKeyword = ModifierToken; /** @deprecated Use `ReadonlyKeyword` instead. */ type ReadonlyToken = ReadonlyKeyword; - type Modifier = AbstractKeyword | AccessorKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; + type Modifier = AbstractKeyword | AccessorKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PreferInferKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; type ModifierLike = Modifier | Decorator; type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 7d4bb8e1d0985..53888e1407522 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -191,223 +191,224 @@ declare namespace ts { NamespaceKeyword = 143, NeverKeyword = 144, OutKeyword = 145, - ReadonlyKeyword = 146, - RequireKeyword = 147, - NumberKeyword = 148, - ObjectKeyword = 149, - SatisfiesKeyword = 150, - 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, + PreferInferKeyword = 146, + ReadonlyKeyword = 147, + RequireKeyword = 148, + NumberKeyword = 149, + ObjectKeyword = 150, + SatisfiesKeyword = 151, + SetKeyword = 152, + StringKeyword = 153, + SymbolKeyword = 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, - JSDocOverloadTag = 342, - JSDocEnumTag = 343, - JSDocParameterTag = 344, - JSDocReturnTag = 345, - JSDocThisTag = 346, - JSDocTypeTag = 347, - JSDocTemplateTag = 348, - JSDocTypedefTag = 349, - JSDocSeeTag = 350, - JSDocPropertyTag = 351, - JSDocThrowsTag = 352, - SyntaxList = 353, - NotEmittedStatement = 354, - PartiallyEmittedExpression = 355, - CommaListExpression = 356, - MergeDeclarationMarker = 357, - EndOfDeclarationMarker = 358, - SyntheticReferenceExpression = 359, - Count = 360, + 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, + JSDocOverloadTag = 343, + JSDocEnumTag = 344, + JSDocParameterTag = 345, + JSDocReturnTag = 346, + JSDocThisTag = 347, + JSDocTypeTag = 348, + JSDocTemplateTag = 349, + JSDocTypedefTag = 350, + JSDocSeeTag = 351, + JSDocPropertyTag = 352, + JSDocThrowsTag = 353, + SyntaxList = 354, + NotEmittedStatement = 355, + PartiallyEmittedExpression = 356, + CommaListExpression = 357, + MergeDeclarationMarker = 358, + EndOfDeclarationMarker = 359, + SyntheticReferenceExpression = 360, + Count = 361, FirstAssignment = 63, LastAssignment = 78, FirstCompoundAssignment = 64, @@ -415,15 +416,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, @@ -432,20 +433,20 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 78, - FirstStatement = 240, - LastStatement = 256, - FirstNode = 163, - FirstJSDocNode = 312, - LastJSDocNode = 352, - FirstJSDocTagNode = 330, - LastJSDocTagNode = 352 + FirstStatement = 241, + LastStatement = 257, + FirstNode = 164, + FirstJSDocNode = 313, + LastJSDocNode = 353, + FirstJSDocTagNode = 331, + LastJSDocTagNode = 353 } 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 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 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.PreferInferKeyword | 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 ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PreferInferKeyword | 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; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; @@ -501,14 +502,15 @@ declare namespace ts { In = 32768, Out = 65536, Decorator = 131072, + PreferInfer = 262144, HasComputedFlags = 536870912, AccessibilityModifier = 28, ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, - TypeScriptModifier = 117086, + TypeScriptModifier = 379230, ExportDefault = 1025, - All = 258047, - Modifier = 126975 + All = 520191, + Modifier = 389119 } enum JsxFlags { None = 0, @@ -620,6 +622,7 @@ declare namespace ts { type DefaultKeyword = ModifierToken; type ExportKeyword = ModifierToken; type InKeyword = ModifierToken; + type PreferInferKeyword = ModifierToken; type PrivateKeyword = ModifierToken; type ProtectedKeyword = ModifierToken; type PublicKeyword = ModifierToken; @@ -629,7 +632,7 @@ declare namespace ts { type StaticKeyword = ModifierToken; /** @deprecated Use `ReadonlyKeyword` instead. */ type ReadonlyToken = ReadonlyKeyword; - type Modifier = AbstractKeyword | AccessorKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; + type Modifier = AbstractKeyword | AccessorKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PreferInferKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; type ModifierLike = Modifier | Decorator; type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; diff --git a/tests/baselines/reference/inferPartialTypeArguments.js b/tests/baselines/reference/inferPartialTypeArguments.js new file mode 100644 index 0000000000000..2879a197ea229 --- /dev/null +++ b/tests/baselines/reference/inferPartialTypeArguments.js @@ -0,0 +1,145 @@ +//// [inferPartialTypeArguments.tsx] +declare module JSX { + interface Element {} + interface IntrinsicElements { + h: {} + } +} +declare namespace React { + export function createElement( + x: any, + p: any, + ...children: any[] + ): JSX.Element; +} +class Foo { + constructor(public prop1: T, public prop2: U) {} +} +function foo(x: T, y: U): [T, U] { + return [x, y]; +} +interface ComponentProps { + x: T; + y: U; + cb(props: this): void; +} +function Component(x: ComponentProps) { + return ; +} + +const instance1 = new Foo(0, ""); +const result1 = foo(0, ""); +const jsx1 = ( + + x={12} + y="" + cb={(props) => void (props.x.toFixed() + props.y.toUpperCase())} + /> +); + +declare function stillDefaultsIfNoInference< + X, + preferinfer A = string, + preferinfer B = number, + preferinfer C = boolean +>(arg: { a?: A; b?: B; c?: C; x?: X }): { a: A; b: B; c: C; x: X }; +const result4 = stillDefaultsIfNoInference({ b: "test" }); + +class Foo2 { + constructor(public a: A, public b: B) {} +} +const x = new Foo2('test', { x: 'foo', z: 100 }); +x.a; +x.b.x; +x.b.z; + + +//// [inferPartialTypeArguments.js] +"use strict"; +var Foo = /** @class */ (function () { + function Foo(prop1, prop2) { + this.prop1 = prop1; + this.prop2 = prop2; + } + return Foo; +}()); +function foo(x, y) { + return [x, y]; +} +function Component(x) { + return React.createElement("h", null); +} +var instance1 = new Foo(0, ""); +var result1 = foo(0, ""); +var jsx1 = (React.createElement(Component, { x: 12, y: "", cb: function (props) { return void (props.x.toFixed() + props.y.toUpperCase()); } })); +var result4 = stillDefaultsIfNoInference({ b: "test" }); +var Foo2 = /** @class */ (function () { + function Foo2(a, b) { + this.a = a; + this.b = b; + } + return Foo2; +}()); +var x = new Foo2('test', { x: 'foo', z: 100 }); +x.a; +x.b.x; +x.b.z; + + +//// [inferPartialTypeArguments.d.ts] +declare module JSX { + interface Element { + } + interface IntrinsicElements { + h: {}; + } +} +declare namespace React { + function createElement(x: any, p: any, ...children: any[]): JSX.Element; +} +declare class Foo { + prop1: T; + prop2: U; + constructor(prop1: T, prop2: U); +} +declare function foo(x: T, y: U): [T, U]; +interface ComponentProps { + x: T; + y: U; + cb(props: this): void; +} +declare function Component(x: ComponentProps): JSX.Element; +declare const instance1: Foo; +declare const result1: [number, string]; +declare const jsx1: JSX.Element; +declare function stillDefaultsIfNoInference(arg: { + a?: A; + b?: B; + c?: C; + x?: X; +}): { + a: A; + b: B; + c: C; + x: X; +}; +declare const result4: { + a: string; + b: string; + c: boolean; + x: object; +}; +declare class Foo2 { + a: A; + b: B; + constructor(a: A, b: B); +} +declare const x: Foo2; diff --git a/tests/baselines/reference/inferPartialTypeArguments.symbols b/tests/baselines/reference/inferPartialTypeArguments.symbols new file mode 100644 index 0000000000000..a0c747080d4cf --- /dev/null +++ b/tests/baselines/reference/inferPartialTypeArguments.symbols @@ -0,0 +1,205 @@ +=== tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArguments.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(inferPartialTypeArguments.tsx, 0, 0)) + + interface Element {} +>Element : Symbol(Element, Decl(inferPartialTypeArguments.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(inferPartialTypeArguments.tsx, 1, 22)) + + h: {} +>h : Symbol(IntrinsicElements.h, Decl(inferPartialTypeArguments.tsx, 2, 31)) + } +} +declare namespace React { +>React : Symbol(React, Decl(inferPartialTypeArguments.tsx, 5, 1)) + + export function createElement( +>createElement : Symbol(createElement, Decl(inferPartialTypeArguments.tsx, 6, 25)) + + x: any, +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 7, 32)) + + p: any, +>p : Symbol(p, Decl(inferPartialTypeArguments.tsx, 8, 11)) + + ...children: any[] +>children : Symbol(children, Decl(inferPartialTypeArguments.tsx, 9, 11)) + + ): JSX.Element; +>JSX : Symbol(JSX, Decl(inferPartialTypeArguments.tsx, 0, 0)) +>Element : Symbol(JSX.Element, Decl(inferPartialTypeArguments.tsx, 0, 20)) +} +class Foo { +>Foo : Symbol(Foo, Decl(inferPartialTypeArguments.tsx, 12, 1)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 13, 10)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 13, 12)) + + constructor(public prop1: T, public prop2: U) {} +>prop1 : Symbol(Foo.prop1, Decl(inferPartialTypeArguments.tsx, 14, 14)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 13, 10)) +>prop2 : Symbol(Foo.prop2, Decl(inferPartialTypeArguments.tsx, 14, 30)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 13, 12)) +} +function foo(x: T, y: U): [T, U] { +>foo : Symbol(foo, Decl(inferPartialTypeArguments.tsx, 15, 1)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 16, 13)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 16, 15)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 16, 31)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 16, 13)) +>y : Symbol(y, Decl(inferPartialTypeArguments.tsx, 16, 36)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 16, 15)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 16, 13)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 16, 15)) + + return [x, y]; +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 16, 31)) +>y : Symbol(y, Decl(inferPartialTypeArguments.tsx, 16, 36)) +} +interface ComponentProps { +>ComponentProps : Symbol(ComponentProps, Decl(inferPartialTypeArguments.tsx, 18, 1)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 19, 25)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 19, 27)) + + x: T; +>x : Symbol(ComponentProps.x, Decl(inferPartialTypeArguments.tsx, 19, 32)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 19, 25)) + + y: U; +>y : Symbol(ComponentProps.y, Decl(inferPartialTypeArguments.tsx, 20, 7)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 19, 27)) + + cb(props: this): void; +>cb : Symbol(ComponentProps.cb, Decl(inferPartialTypeArguments.tsx, 21, 7)) +>props : Symbol(props, Decl(inferPartialTypeArguments.tsx, 22, 5)) +} +function Component(x: ComponentProps) { +>Component : Symbol(Component, Decl(inferPartialTypeArguments.tsx, 23, 1)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 24, 19)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 24, 21)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 24, 37)) +>ComponentProps : Symbol(ComponentProps, Decl(inferPartialTypeArguments.tsx, 18, 1)) +>T : Symbol(T, Decl(inferPartialTypeArguments.tsx, 24, 19)) +>U : Symbol(U, Decl(inferPartialTypeArguments.tsx, 24, 21)) + + return ; +>h : Symbol(JSX.IntrinsicElements.h, Decl(inferPartialTypeArguments.tsx, 2, 31)) +>h : Symbol(JSX.IntrinsicElements.h, Decl(inferPartialTypeArguments.tsx, 2, 31)) +} + +const instance1 = new Foo(0, ""); +>instance1 : Symbol(instance1, Decl(inferPartialTypeArguments.tsx, 28, 5)) +>Foo : Symbol(Foo, Decl(inferPartialTypeArguments.tsx, 12, 1)) + +const result1 = foo(0, ""); +>result1 : Symbol(result1, Decl(inferPartialTypeArguments.tsx, 29, 5)) +>foo : Symbol(foo, Decl(inferPartialTypeArguments.tsx, 15, 1)) + +const jsx1 = ( +>jsx1 : Symbol(jsx1, Decl(inferPartialTypeArguments.tsx, 30, 5)) + + +>Component : Symbol(Component, Decl(inferPartialTypeArguments.tsx, 23, 1)) + + x={12} +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 31, 20)) + + y="" +>y : Symbol(y, Decl(inferPartialTypeArguments.tsx, 32, 10)) + + cb={(props) => void (props.x.toFixed() + props.y.toUpperCase())} +>cb : Symbol(cb, Decl(inferPartialTypeArguments.tsx, 33, 8)) +>props : Symbol(props, Decl(inferPartialTypeArguments.tsx, 34, 9)) +>props.x.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>props.x : Symbol(ComponentProps.x, Decl(inferPartialTypeArguments.tsx, 19, 32)) +>props : Symbol(props, Decl(inferPartialTypeArguments.tsx, 34, 9)) +>x : Symbol(ComponentProps.x, Decl(inferPartialTypeArguments.tsx, 19, 32)) +>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) +>props.y.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) +>props.y : Symbol(ComponentProps.y, Decl(inferPartialTypeArguments.tsx, 20, 7)) +>props : Symbol(props, Decl(inferPartialTypeArguments.tsx, 34, 9)) +>y : Symbol(ComponentProps.y, Decl(inferPartialTypeArguments.tsx, 20, 7)) +>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --)) + + /> +); + +declare function stillDefaultsIfNoInference< +>stillDefaultsIfNoInference : Symbol(stillDefaultsIfNoInference, Decl(inferPartialTypeArguments.tsx, 36, 2)) + + X, +>X : Symbol(X, Decl(inferPartialTypeArguments.tsx, 38, 44)) + + preferinfer A = string, +>A : Symbol(A, Decl(inferPartialTypeArguments.tsx, 39, 4)) + + preferinfer B = number, +>B : Symbol(B, Decl(inferPartialTypeArguments.tsx, 40, 25)) + + preferinfer C = boolean +>C : Symbol(C, Decl(inferPartialTypeArguments.tsx, 41, 25)) + +>(arg: { a?: A; b?: B; c?: C; x?: X }): { a: A; b: B; c: C; x: X }; +>arg : Symbol(arg, Decl(inferPartialTypeArguments.tsx, 43, 2)) +>a : Symbol(a, Decl(inferPartialTypeArguments.tsx, 43, 8)) +>A : Symbol(A, Decl(inferPartialTypeArguments.tsx, 39, 4)) +>b : Symbol(b, Decl(inferPartialTypeArguments.tsx, 43, 15)) +>B : Symbol(B, Decl(inferPartialTypeArguments.tsx, 40, 25)) +>c : Symbol(c, Decl(inferPartialTypeArguments.tsx, 43, 22)) +>C : Symbol(C, Decl(inferPartialTypeArguments.tsx, 41, 25)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 43, 29)) +>X : Symbol(X, Decl(inferPartialTypeArguments.tsx, 38, 44)) +>a : Symbol(a, Decl(inferPartialTypeArguments.tsx, 43, 41)) +>A : Symbol(A, Decl(inferPartialTypeArguments.tsx, 39, 4)) +>b : Symbol(b, Decl(inferPartialTypeArguments.tsx, 43, 47)) +>B : Symbol(B, Decl(inferPartialTypeArguments.tsx, 40, 25)) +>c : Symbol(c, Decl(inferPartialTypeArguments.tsx, 43, 53)) +>C : Symbol(C, Decl(inferPartialTypeArguments.tsx, 41, 25)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 43, 59)) +>X : Symbol(X, Decl(inferPartialTypeArguments.tsx, 38, 44)) + +const result4 = stillDefaultsIfNoInference({ b: "test" }); +>result4 : Symbol(result4, Decl(inferPartialTypeArguments.tsx, 44, 5)) +>stillDefaultsIfNoInference : Symbol(stillDefaultsIfNoInference, Decl(inferPartialTypeArguments.tsx, 36, 2)) +>b : Symbol(b, Decl(inferPartialTypeArguments.tsx, 44, 52)) + +class Foo2 { +>Foo2 : Symbol(Foo2, Decl(inferPartialTypeArguments.tsx, 44, 66)) +>A : Symbol(A, Decl(inferPartialTypeArguments.tsx, 46, 11)) +>B : Symbol(B, Decl(inferPartialTypeArguments.tsx, 46, 22)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 46, 46)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 46, 62)) +>y : Symbol(y, Decl(inferPartialTypeArguments.tsx, 46, 73)) + + constructor(public a: A, public b: B) {} +>a : Symbol(Foo2.a, Decl(inferPartialTypeArguments.tsx, 47, 14)) +>A : Symbol(A, Decl(inferPartialTypeArguments.tsx, 46, 11)) +>b : Symbol(Foo2.b, Decl(inferPartialTypeArguments.tsx, 47, 26)) +>B : Symbol(B, Decl(inferPartialTypeArguments.tsx, 46, 22)) +} +const x = new Foo2('test', { x: 'foo', z: 100 }); +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 49, 5)) +>Foo2 : Symbol(Foo2, Decl(inferPartialTypeArguments.tsx, 44, 66)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 49, 36)) +>z : Symbol(z, Decl(inferPartialTypeArguments.tsx, 49, 46)) + +x.a; +>x.a : Symbol(Foo2.a, Decl(inferPartialTypeArguments.tsx, 47, 14)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 49, 5)) +>a : Symbol(Foo2.a, Decl(inferPartialTypeArguments.tsx, 47, 14)) + +x.b.x; +>x.b.x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 49, 36)) +>x.b : Symbol(Foo2.b, Decl(inferPartialTypeArguments.tsx, 47, 26)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 49, 5)) +>b : Symbol(Foo2.b, Decl(inferPartialTypeArguments.tsx, 47, 26)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 49, 36)) + +x.b.z; +>x.b.z : Symbol(z, Decl(inferPartialTypeArguments.tsx, 49, 46)) +>x.b : Symbol(Foo2.b, Decl(inferPartialTypeArguments.tsx, 47, 26)) +>x : Symbol(x, Decl(inferPartialTypeArguments.tsx, 49, 5)) +>b : Symbol(Foo2.b, Decl(inferPartialTypeArguments.tsx, 47, 26)) +>z : Symbol(z, Decl(inferPartialTypeArguments.tsx, 49, 46)) + diff --git a/tests/baselines/reference/inferPartialTypeArguments.types b/tests/baselines/reference/inferPartialTypeArguments.types new file mode 100644 index 0000000000000..510012d6b4c55 --- /dev/null +++ b/tests/baselines/reference/inferPartialTypeArguments.types @@ -0,0 +1,182 @@ +=== tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArguments.tsx === +declare module JSX { + interface Element {} + interface IntrinsicElements { + h: {} +>h : {} + } +} +declare namespace React { +>React : typeof React + + export function createElement( +>createElement : (x: any, p: any, ...children: any[]) => JSX.Element + + x: any, +>x : any + + p: any, +>p : any + + ...children: any[] +>children : any[] + + ): JSX.Element; +>JSX : any +} +class Foo { +>Foo : Foo + + constructor(public prop1: T, public prop2: U) {} +>prop1 : T +>prop2 : U +} +function foo(x: T, y: U): [T, U] { +>foo : (x: T, y: U) => [T, U] +>x : T +>y : U + + return [x, y]; +>[x, y] : [T, U] +>x : T +>y : U +} +interface ComponentProps { + x: T; +>x : T + + y: U; +>y : U + + cb(props: this): void; +>cb : (props: this) => void +>props : this +} +function Component(x: ComponentProps) { +>Component : (x: ComponentProps) => JSX.Element +>x : ComponentProps + + return ; +> : JSX.Element +>h : any +>h : any +} + +const instance1 = new Foo(0, ""); +>instance1 : Foo +>new Foo(0, "") : Foo +>Foo : typeof Foo +>0 : 0 +>"" : "" + +const result1 = foo(0, ""); +>result1 : [number, string] +>foo(0, "") : [number, string] +>foo : (x: T, y: U) => [T, U] +>0 : 0 +>"" : "" + +const jsx1 = ( +>jsx1 : JSX.Element +>( x={12} y="" cb={(props) => void (props.x.toFixed() + props.y.toUpperCase())} />) : JSX.Element + + +> x={12} y="" cb={(props) => void (props.x.toFixed() + props.y.toUpperCase())} /> : JSX.Element +>Component : (x: ComponentProps) => JSX.Element + + x={12} +>x : number +>12 : 12 + + y="" +>y : string + + cb={(props) => void (props.x.toFixed() + props.y.toUpperCase())} +>cb : (props: ComponentProps) => undefined +>(props) => void (props.x.toFixed() + props.y.toUpperCase()) : (props: ComponentProps) => undefined +>props : ComponentProps +>void (props.x.toFixed() + props.y.toUpperCase()) : undefined +>(props.x.toFixed() + props.y.toUpperCase()) : string +>props.x.toFixed() + props.y.toUpperCase() : string +>props.x.toFixed() : string +>props.x.toFixed : (fractionDigits?: number | undefined) => string +>props.x : number +>props : ComponentProps +>x : number +>toFixed : (fractionDigits?: number | undefined) => string +>props.y.toUpperCase() : string +>props.y.toUpperCase : () => string +>props.y : string +>props : ComponentProps +>y : string +>toUpperCase : () => string + + /> +); + +declare function stillDefaultsIfNoInference< +>stillDefaultsIfNoInference : (arg: { a?: A; b?: B; c?: C; x?: X;}) => { a: A; b: B; c: C; x: X;} + + X, + preferinfer A = string, + preferinfer B = number, + preferinfer C = boolean +>(arg: { a?: A; b?: B; c?: C; x?: X }): { a: A; b: B; c: C; x: X }; +>arg : { a?: A | undefined; b?: B | undefined; c?: C | undefined; x?: X | undefined; } +>a : A | undefined +>b : B | undefined +>c : C | undefined +>x : X | undefined +>a : A +>b : B +>c : C +>x : X + +const result4 = stillDefaultsIfNoInference({ b: "test" }); +>result4 : { a: string; b: string; c: boolean; x: object; } +>stillDefaultsIfNoInference({ b: "test" }) : { a: string; b: string; c: boolean; x: object; } +>stillDefaultsIfNoInference : (arg: { a?: A | undefined; b?: B | undefined; c?: C | undefined; x?: X | undefined; }) => { a: A; b: B; c: C; x: X; } +>{ b: "test" } : { b: string; } +>b : string +>"test" : "test" + +class Foo2 { +>Foo2 : Foo2 +>x : string +>x : string +>y : number + + constructor(public a: A, public b: B) {} +>a : A +>b : B +} +const x = new Foo2('test', { x: 'foo', z: 100 }); +>x : Foo2 +>new Foo2('test', { x: 'foo', z: 100 }) : Foo2 +>Foo2 : typeof Foo2 +>'test' : "test" +>{ x: 'foo', z: 100 } : { x: string; z: number; } +>x : string +>'foo' : "foo" +>z : number +>100 : 100 + +x.a; +>x.a : string +>x : Foo2 +>a : string + +x.b.x; +>x.b.x : string +>x.b : { x: string; z: number; } +>x : Foo2 +>b : { x: string; z: number; } +>x : string + +x.b.z; +>x.b.z : number +>x.b : { x: string; z: number; } +>x : Foo2 +>b : { x: string; z: number; } +>z : number + diff --git a/tests/baselines/reference/inferPartialTypeArgumentsErrors.errors.txt b/tests/baselines/reference/inferPartialTypeArgumentsErrors.errors.txt new file mode 100644 index 0000000000000..4ec277b88660a --- /dev/null +++ b/tests/baselines/reference/inferPartialTypeArgumentsErrors.errors.txt @@ -0,0 +1,55 @@ +tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts(5,50): error TS2322: Type '"x"' is not assignable to type '"z"'. +tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts(5,55): error TS2322: Type '"y"' is not assignable to type '"z"'. +tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts(19,66): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. +tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts(30,53): error TS2322: Type '"y"' is not assignable to type '"x"'. + + +==== tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts (4 errors) ==== + declare function testConstraints1(arg?: { + a?: A[]; + b?: B[]; + }): { a: A[]; b: B[] }; + const expectError1 = testConstraints1<"z">({ b: ["x", "y"] }); + ~~~ +!!! error TS2322: Type '"x"' is not assignable to type '"z"'. + ~~~ +!!! error TS2322: Type '"y"' is not assignable to type '"z"'. + + declare function testConstraints2(arg?: { + a?: A[]; + b?: B[]; + }): { a: A[]; b: B[] }; + const expectAllowed1 = testConstraints2<"x">({ b: ["x", "y"] }); + const expectError2 = testConstraints2<"z">({ b: ["x", "y"] }); + + declare function testConstraints3(arg?: { + a?: A[]; + b?: B[]; + }): { a: A[]; b: B[] }; + const expectAllowed3 = testConstraints3<"x" | "y">({ b: ["x"] }); + const expectError3 = testConstraints3<"x" | "y">({ b: ["x", "y", "z"] }); + ~~~ +!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. + + declare function complexConstraints1< + A extends string, + preferinfer B extends A, + preferinfer C extends B + >(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; + const expectAllowed4 = complexConstraints1<"x" | "y" | "z">({ + a: ["x"], + c: ["x", "y"], + }); + const expectError5 = complexConstraints1<"x">({ c: ["y"] }); + ~~~ +!!! error TS2322: Type '"y"' is not assignable to type '"x"'. + + declare function complexConstraints2< + A extends string, + preferinfer B extends C, + preferinfer C extends A + >(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; + const expectError4 = complexConstraints2<"x" | "y" | "z", "x" | "y">({ + c: ["x"], + }); + \ No newline at end of file diff --git a/tests/baselines/reference/inferPartialTypeArgumentsErrors.js b/tests/baselines/reference/inferPartialTypeArgumentsErrors.js new file mode 100644 index 0000000000000..4ee2255f6013f --- /dev/null +++ b/tests/baselines/reference/inferPartialTypeArgumentsErrors.js @@ -0,0 +1,134 @@ +//// [inferPartialTypeArgumentsErrors.ts] +declare function testConstraints1(arg?: { + a?: A[]; + b?: B[]; +}): { a: A[]; b: B[] }; +const expectError1 = testConstraints1<"z">({ b: ["x", "y"] }); + +declare function testConstraints2(arg?: { + a?: A[]; + b?: B[]; +}): { a: A[]; b: B[] }; +const expectAllowed1 = testConstraints2<"x">({ b: ["x", "y"] }); +const expectError2 = testConstraints2<"z">({ b: ["x", "y"] }); + +declare function testConstraints3(arg?: { + a?: A[]; + b?: B[]; +}): { a: A[]; b: B[] }; +const expectAllowed3 = testConstraints3<"x" | "y">({ b: ["x"] }); +const expectError3 = testConstraints3<"x" | "y">({ b: ["x", "y", "z"] }); + +declare function complexConstraints1< + A extends string, + preferinfer B extends A, + preferinfer C extends B +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +const expectAllowed4 = complexConstraints1<"x" | "y" | "z">({ + a: ["x"], + c: ["x", "y"], +}); +const expectError5 = complexConstraints1<"x">({ c: ["y"] }); + +declare function complexConstraints2< + A extends string, + preferinfer B extends C, + preferinfer C extends A +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +const expectError4 = complexConstraints2<"x" | "y" | "z", "x" | "y">({ + c: ["x"], +}); + + +//// [inferPartialTypeArgumentsErrors.js] +"use strict"; +var expectError1 = testConstraints1({ b: ["x", "y"] }); +var expectAllowed1 = testConstraints2({ b: ["x", "y"] }); +var expectError2 = testConstraints2({ b: ["x", "y"] }); +var expectAllowed3 = testConstraints3({ b: ["x"] }); +var expectError3 = testConstraints3({ b: ["x", "y", "z"] }); +var expectAllowed4 = complexConstraints1({ + a: ["x"], + c: ["x", "y"], +}); +var expectError5 = complexConstraints1({ c: ["y"] }); +var expectError4 = complexConstraints2({ + c: ["x"], +}); + + +//// [inferPartialTypeArgumentsErrors.d.ts] +declare function testConstraints1(arg?: { + a?: A[]; + b?: B[]; +}): { + a: A[]; + b: B[]; +}; +declare const expectError1: { + a: "z"[]; + b: A[]; +}; +declare function testConstraints2(arg?: { + a?: A[]; + b?: B[]; +}): { + a: A[]; + b: B[]; +}; +declare const expectAllowed1: { + a: "x"[]; + b: ("x" | "y")[]; +}; +declare const expectError2: { + a: "z"[]; + b: ("x" | "y")[]; +}; +declare function testConstraints3(arg?: { + a?: A[]; + b?: B[]; +}): { + a: A[]; + b: B[]; +}; +declare const expectAllowed3: { + a: ("x" | "y")[]; + b: "x"[]; +}; +declare const expectError3: { + a: ("x" | "y")[]; + b: A[]; +}; +declare function complexConstraints1(arg: { + a?: A[]; + b?: B[]; + c?: C[]; +}): { + a: A[]; + b: B[]; + c: C[]; +}; +declare const expectAllowed4: { + a: ("z" | "x" | "y")[]; + b: ("z" | "x" | "y")[]; + c: ("x" | "y")[]; +}; +declare const expectError5: { + a: "x"[]; + b: A[]; + c: B[]; +}; +declare function complexConstraints2(arg: { + a?: A[]; + b?: B[]; + c?: C[]; +}): { + a: A[]; + b: B[]; + c: C[]; +}; +declare const expectError4: { + a: ("z" | "x" | "y")[]; + b: ("x" | "y")[]; + c: "x"[]; +}; diff --git a/tests/baselines/reference/inferPartialTypeArgumentsErrors.symbols b/tests/baselines/reference/inferPartialTypeArgumentsErrors.symbols new file mode 100644 index 0000000000000..26728511e2fb1 --- /dev/null +++ b/tests/baselines/reference/inferPartialTypeArgumentsErrors.symbols @@ -0,0 +1,172 @@ +=== tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts === +declare function testConstraints1(arg?: { +>testConstraints1 : Symbol(testConstraints1, Decl(inferPartialTypeArgumentsErrors.ts, 0, 0)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 0, 34)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 0, 51)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 0, 34)) +>arg : Symbol(arg, Decl(inferPartialTypeArgumentsErrors.ts, 0, 77)) + + a?: A[]; +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 0, 84)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 0, 34)) + + b?: B[]; +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 1, 10)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 0, 51)) + +}): { a: A[]; b: B[] }; +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 3, 5)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 0, 34)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 3, 13)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 0, 51)) + +const expectError1 = testConstraints1<"z">({ b: ["x", "y"] }); +>expectError1 : Symbol(expectError1, Decl(inferPartialTypeArgumentsErrors.ts, 4, 5)) +>testConstraints1 : Symbol(testConstraints1, Decl(inferPartialTypeArgumentsErrors.ts, 0, 0)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 4, 44)) + +declare function testConstraints2(arg?: { +>testConstraints2 : Symbol(testConstraints2, Decl(inferPartialTypeArgumentsErrors.ts, 4, 62)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 6, 34)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 6, 46)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 6, 46)) +>arg : Symbol(arg, Decl(inferPartialTypeArgumentsErrors.ts, 6, 77)) + + a?: A[]; +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 6, 84)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 6, 34)) + + b?: B[]; +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 7, 10)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 6, 46)) + +}): { a: A[]; b: B[] }; +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 9, 5)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 6, 34)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 9, 13)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 6, 46)) + +const expectAllowed1 = testConstraints2<"x">({ b: ["x", "y"] }); +>expectAllowed1 : Symbol(expectAllowed1, Decl(inferPartialTypeArgumentsErrors.ts, 10, 5)) +>testConstraints2 : Symbol(testConstraints2, Decl(inferPartialTypeArgumentsErrors.ts, 4, 62)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 10, 46)) + +const expectError2 = testConstraints2<"z">({ b: ["x", "y"] }); +>expectError2 : Symbol(expectError2, Decl(inferPartialTypeArgumentsErrors.ts, 11, 5)) +>testConstraints2 : Symbol(testConstraints2, Decl(inferPartialTypeArgumentsErrors.ts, 4, 62)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 11, 44)) + +declare function testConstraints3(arg?: { +>testConstraints3 : Symbol(testConstraints3, Decl(inferPartialTypeArgumentsErrors.ts, 11, 62)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 13, 34)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 13, 51)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 13, 34)) +>arg : Symbol(arg, Decl(inferPartialTypeArgumentsErrors.ts, 13, 77)) + + a?: A[]; +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 13, 84)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 13, 34)) + + b?: B[]; +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 14, 10)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 13, 51)) + +}): { a: A[]; b: B[] }; +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 16, 5)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 13, 34)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 16, 13)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 13, 51)) + +const expectAllowed3 = testConstraints3<"x" | "y">({ b: ["x"] }); +>expectAllowed3 : Symbol(expectAllowed3, Decl(inferPartialTypeArgumentsErrors.ts, 17, 5)) +>testConstraints3 : Symbol(testConstraints3, Decl(inferPartialTypeArgumentsErrors.ts, 11, 62)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 17, 52)) + +const expectError3 = testConstraints3<"x" | "y">({ b: ["x", "y", "z"] }); +>expectError3 : Symbol(expectError3, Decl(inferPartialTypeArgumentsErrors.ts, 18, 5)) +>testConstraints3 : Symbol(testConstraints3, Decl(inferPartialTypeArgumentsErrors.ts, 11, 62)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 18, 50)) + +declare function complexConstraints1< +>complexConstraints1 : Symbol(complexConstraints1, Decl(inferPartialTypeArgumentsErrors.ts, 18, 73)) + + A extends string, +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 20, 37)) + + preferinfer B extends A, +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 21, 19)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 20, 37)) + + preferinfer C extends B +>C : Symbol(C, Decl(inferPartialTypeArgumentsErrors.ts, 22, 26)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 21, 19)) + +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +>arg : Symbol(arg, Decl(inferPartialTypeArgumentsErrors.ts, 24, 2)) +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 24, 8)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 20, 37)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 24, 17)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 21, 19)) +>c : Symbol(c, Decl(inferPartialTypeArgumentsErrors.ts, 24, 26)) +>C : Symbol(C, Decl(inferPartialTypeArgumentsErrors.ts, 22, 26)) +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 24, 40)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 20, 37)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 24, 48)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 21, 19)) +>c : Symbol(c, Decl(inferPartialTypeArgumentsErrors.ts, 24, 56)) +>C : Symbol(C, Decl(inferPartialTypeArgumentsErrors.ts, 22, 26)) + +const expectAllowed4 = complexConstraints1<"x" | "y" | "z">({ +>expectAllowed4 : Symbol(expectAllowed4, Decl(inferPartialTypeArgumentsErrors.ts, 25, 5)) +>complexConstraints1 : Symbol(complexConstraints1, Decl(inferPartialTypeArgumentsErrors.ts, 18, 73)) + + a: ["x"], +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 25, 61)) + + c: ["x", "y"], +>c : Symbol(c, Decl(inferPartialTypeArgumentsErrors.ts, 26, 11)) + +}); +const expectError5 = complexConstraints1<"x">({ c: ["y"] }); +>expectError5 : Symbol(expectError5, Decl(inferPartialTypeArgumentsErrors.ts, 29, 5)) +>complexConstraints1 : Symbol(complexConstraints1, Decl(inferPartialTypeArgumentsErrors.ts, 18, 73)) +>c : Symbol(c, Decl(inferPartialTypeArgumentsErrors.ts, 29, 47)) + +declare function complexConstraints2< +>complexConstraints2 : Symbol(complexConstraints2, Decl(inferPartialTypeArgumentsErrors.ts, 29, 60)) + + A extends string, +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 31, 37)) + + preferinfer B extends C, +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 32, 19)) +>C : Symbol(C, Decl(inferPartialTypeArgumentsErrors.ts, 33, 26)) + + preferinfer C extends A +>C : Symbol(C, Decl(inferPartialTypeArgumentsErrors.ts, 33, 26)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 31, 37)) + +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +>arg : Symbol(arg, Decl(inferPartialTypeArgumentsErrors.ts, 35, 2)) +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 35, 8)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 31, 37)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 35, 17)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 32, 19)) +>c : Symbol(c, Decl(inferPartialTypeArgumentsErrors.ts, 35, 26)) +>C : Symbol(C, Decl(inferPartialTypeArgumentsErrors.ts, 33, 26)) +>a : Symbol(a, Decl(inferPartialTypeArgumentsErrors.ts, 35, 40)) +>A : Symbol(A, Decl(inferPartialTypeArgumentsErrors.ts, 31, 37)) +>b : Symbol(b, Decl(inferPartialTypeArgumentsErrors.ts, 35, 48)) +>B : Symbol(B, Decl(inferPartialTypeArgumentsErrors.ts, 32, 19)) +>c : Symbol(c, Decl(inferPartialTypeArgumentsErrors.ts, 35, 56)) +>C : Symbol(C, Decl(inferPartialTypeArgumentsErrors.ts, 33, 26)) + +const expectError4 = complexConstraints2<"x" | "y" | "z", "x" | "y">({ +>expectError4 : Symbol(expectError4, Decl(inferPartialTypeArgumentsErrors.ts, 36, 5)) +>complexConstraints2 : Symbol(complexConstraints2, Decl(inferPartialTypeArgumentsErrors.ts, 29, 60)) + + c: ["x"], +>c : Symbol(c, Decl(inferPartialTypeArgumentsErrors.ts, 36, 70)) + +}); + diff --git a/tests/baselines/reference/inferPartialTypeArgumentsErrors.types b/tests/baselines/reference/inferPartialTypeArgumentsErrors.types new file mode 100644 index 0000000000000..052d2fde5a67c --- /dev/null +++ b/tests/baselines/reference/inferPartialTypeArgumentsErrors.types @@ -0,0 +1,163 @@ +=== tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts === +declare function testConstraints1(arg?: { +>testConstraints1 : (arg?: { a?: A[]; b?: B[];}) => { a: A[]; b: B[];} +>arg : { a?: A[] | undefined; b?: B[] | undefined; } | undefined + + a?: A[]; +>a : A[] | undefined + + b?: B[]; +>b : B[] | undefined + +}): { a: A[]; b: B[] }; +>a : A[] +>b : B[] + +const expectError1 = testConstraints1<"z">({ b: ["x", "y"] }); +>expectError1 : { a: "z"[]; b: A[]; } +>testConstraints1<"z">({ b: ["x", "y"] }) : { a: "z"[]; b: A[]; } +>testConstraints1 : (arg?: { a?: A[] | undefined; b?: B[] | undefined; } | undefined) => { a: A[]; b: B[]; } +>{ b: ["x", "y"] } : { b: ("x" | "y")[]; } +>b : ("x" | "y")[] +>["x", "y"] : ("x" | "y")[] +>"x" : "x" +>"y" : "y" + +declare function testConstraints2(arg?: { +>testConstraints2 : (arg?: { a?: A[]; b?: B[];}) => { a: A[]; b: B[];} +>arg : { a?: A[] | undefined; b?: B[] | undefined; } | undefined + + a?: A[]; +>a : A[] | undefined + + b?: B[]; +>b : B[] | undefined + +}): { a: A[]; b: B[] }; +>a : A[] +>b : B[] + +const expectAllowed1 = testConstraints2<"x">({ b: ["x", "y"] }); +>expectAllowed1 : { a: "x"[]; b: ("x" | "y")[]; } +>testConstraints2<"x">({ b: ["x", "y"] }) : { a: "x"[]; b: ("x" | "y")[]; } +>testConstraints2 : (arg?: { a?: A[] | undefined; b?: B[] | undefined; } | undefined) => { a: A[]; b: B[]; } +>{ b: ["x", "y"] } : { b: ("x" | "y")[]; } +>b : ("x" | "y")[] +>["x", "y"] : ("x" | "y")[] +>"x" : "x" +>"y" : "y" + +const expectError2 = testConstraints2<"z">({ b: ["x", "y"] }); +>expectError2 : { a: "z"[]; b: ("x" | "y")[]; } +>testConstraints2<"z">({ b: ["x", "y"] }) : { a: "z"[]; b: ("x" | "y")[]; } +>testConstraints2 : (arg?: { a?: A[] | undefined; b?: B[] | undefined; } | undefined) => { a: A[]; b: B[]; } +>{ b: ["x", "y"] } : { b: ("x" | "y")[]; } +>b : ("x" | "y")[] +>["x", "y"] : ("x" | "y")[] +>"x" : "x" +>"y" : "y" + +declare function testConstraints3(arg?: { +>testConstraints3 : (arg?: { a?: A[]; b?: B[];}) => { a: A[]; b: B[];} +>arg : { a?: A[] | undefined; b?: B[] | undefined; } | undefined + + a?: A[]; +>a : A[] | undefined + + b?: B[]; +>b : B[] | undefined + +}): { a: A[]; b: B[] }; +>a : A[] +>b : B[] + +const expectAllowed3 = testConstraints3<"x" | "y">({ b: ["x"] }); +>expectAllowed3 : { a: ("x" | "y")[]; b: "x"[]; } +>testConstraints3<"x" | "y">({ b: ["x"] }) : { a: ("x" | "y")[]; b: "x"[]; } +>testConstraints3 : (arg?: { a?: A[] | undefined; b?: B[] | undefined; } | undefined) => { a: A[]; b: B[]; } +>{ b: ["x"] } : { b: "x"[]; } +>b : "x"[] +>["x"] : "x"[] +>"x" : "x" + +const expectError3 = testConstraints3<"x" | "y">({ b: ["x", "y", "z"] }); +>expectError3 : { a: ("x" | "y")[]; b: A[]; } +>testConstraints3<"x" | "y">({ b: ["x", "y", "z"] }) : { a: ("x" | "y")[]; b: A[]; } +>testConstraints3 : (arg?: { a?: A[] | undefined; b?: B[] | undefined; } | undefined) => { a: A[]; b: B[]; } +>{ b: ["x", "y", "z"] } : { b: ("z" | "x" | "y")[]; } +>b : ("z" | "x" | "y")[] +>["x", "y", "z"] : ("z" | "x" | "y")[] +>"x" : "x" +>"y" : "y" +>"z" : "z" + +declare function complexConstraints1< +>complexConstraints1 : (arg: { a?: A[]; b?: B[]; c?: C[];}) => { a: A[]; b: B[]; c: C[];} + + A extends string, + preferinfer B extends A, + preferinfer C extends B +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +>arg : { a?: A[] | undefined; b?: B[] | undefined; c?: C[] | undefined; } +>a : A[] | undefined +>b : B[] | undefined +>c : C[] | undefined +>a : A[] +>b : B[] +>c : C[] + +const expectAllowed4 = complexConstraints1<"x" | "y" | "z">({ +>expectAllowed4 : { a: ("z" | "x" | "y")[]; b: ("z" | "x" | "y")[]; c: ("x" | "y")[]; } +>complexConstraints1<"x" | "y" | "z">({ a: ["x"], c: ["x", "y"],}) : { a: ("z" | "x" | "y")[]; b: ("z" | "x" | "y")[]; c: ("x" | "y")[]; } +>complexConstraints1 : (arg: { a?: A[] | undefined; b?: B[] | undefined; c?: C[] | undefined; }) => { a: A[]; b: B[]; c: C[]; } +>{ a: ["x"], c: ["x", "y"],} : { a: "x"[]; c: ("x" | "y")[]; } + + a: ["x"], +>a : "x"[] +>["x"] : "x"[] +>"x" : "x" + + c: ["x", "y"], +>c : ("x" | "y")[] +>["x", "y"] : ("x" | "y")[] +>"x" : "x" +>"y" : "y" + +}); +const expectError5 = complexConstraints1<"x">({ c: ["y"] }); +>expectError5 : { a: "x"[]; b: A[]; c: B[]; } +>complexConstraints1<"x">({ c: ["y"] }) : { a: "x"[]; b: A[]; c: B[]; } +>complexConstraints1 : (arg: { a?: A[] | undefined; b?: B[] | undefined; c?: C[] | undefined; }) => { a: A[]; b: B[]; c: C[]; } +>{ c: ["y"] } : { c: "y"[]; } +>c : "y"[] +>["y"] : "y"[] +>"y" : "y" + +declare function complexConstraints2< +>complexConstraints2 : (arg: { a?: A[]; b?: B[]; c?: C[];}) => { a: A[]; b: B[]; c: C[];} + + A extends string, + preferinfer B extends C, + preferinfer C extends A +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +>arg : { a?: A[] | undefined; b?: B[] | undefined; c?: C[] | undefined; } +>a : A[] | undefined +>b : B[] | undefined +>c : C[] | undefined +>a : A[] +>b : B[] +>c : C[] + +const expectError4 = complexConstraints2<"x" | "y" | "z", "x" | "y">({ +>expectError4 : { a: ("z" | "x" | "y")[]; b: ("x" | "y")[]; c: "x"[]; } +>complexConstraints2<"x" | "y" | "z", "x" | "y">({ c: ["x"],}) : { a: ("z" | "x" | "y")[]; b: ("x" | "y")[]; c: "x"[]; } +>complexConstraints2 : (arg: { a?: A[] | undefined; b?: B[] | undefined; c?: C[] | undefined; }) => { a: A[]; b: B[]; c: C[]; } +>{ c: ["x"],} : { c: "x"[]; } + + c: ["x"], +>c : "x"[] +>["x"] : "x"[] +>"x" : "x" + +}); + diff --git a/tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArguments.tsx b/tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArguments.tsx new file mode 100644 index 0000000000000..8809d563019dc --- /dev/null +++ b/tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArguments.tsx @@ -0,0 +1,57 @@ +// @strict: true +// @declaration: true +// @jsx: react + +declare module JSX { + interface Element {} + interface IntrinsicElements { + h: {} + } +} +declare namespace React { + export function createElement( + x: any, + p: any, + ...children: any[] + ): JSX.Element; +} +class Foo { + constructor(public prop1: T, public prop2: U) {} +} +function foo(x: T, y: U): [T, U] { + return [x, y]; +} +interface ComponentProps { + x: T; + y: U; + cb(props: this): void; +} +function Component(x: ComponentProps) { + return ; +} + +const instance1 = new Foo(0, ""); +const result1 = foo(0, ""); +const jsx1 = ( + + x={12} + y="" + cb={(props) => void (props.x.toFixed() + props.y.toUpperCase())} + /> +); + +declare function stillDefaultsIfNoInference< + X, + preferinfer A = string, + preferinfer B = number, + preferinfer C = boolean +>(arg: { a?: A; b?: B; c?: C; x?: X }): { a: A; b: B; c: C; x: X }; +const result4 = stillDefaultsIfNoInference({ b: "test" }); + +class Foo2 { + constructor(public a: A, public b: B) {} +} +const x = new Foo2('test', { x: 'foo', z: 100 }); +x.a; +x.b.x; +x.b.z; diff --git a/tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts b/tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts new file mode 100644 index 0000000000000..34d15a734fffe --- /dev/null +++ b/tests/cases/conformance/types/typeParameters/typeParameterLists/inferPartialTypeArgumentsErrors.ts @@ -0,0 +1,42 @@ +// @strict: true +// @declaration: true + +declare function testConstraints1(arg?: { + a?: A[]; + b?: B[]; +}): { a: A[]; b: B[] }; +const expectError1 = testConstraints1<"z">({ b: ["x", "y"] }); + +declare function testConstraints2(arg?: { + a?: A[]; + b?: B[]; +}): { a: A[]; b: B[] }; +const expectAllowed1 = testConstraints2<"x">({ b: ["x", "y"] }); +const expectError2 = testConstraints2<"z">({ b: ["x", "y"] }); + +declare function testConstraints3(arg?: { + a?: A[]; + b?: B[]; +}): { a: A[]; b: B[] }; +const expectAllowed3 = testConstraints3<"x" | "y">({ b: ["x"] }); +const expectError3 = testConstraints3<"x" | "y">({ b: ["x", "y", "z"] }); + +declare function complexConstraints1< + A extends string, + preferinfer B extends A, + preferinfer C extends B +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +const expectAllowed4 = complexConstraints1<"x" | "y" | "z">({ + a: ["x"], + c: ["x", "y"], +}); +const expectError5 = complexConstraints1<"x">({ c: ["y"] }); + +declare function complexConstraints2< + A extends string, + preferinfer B extends C, + preferinfer C extends A +>(arg: { a?: A[]; b?: B[]; c?: C[] }): { a: A[]; b: B[]; c: C[] }; +const expectError4 = complexConstraints2<"x" | "y" | "z", "x" | "y">({ + c: ["x"], +});