From 68b41e95bc15410fdac53f8f97a74afe832e3bf0 Mon Sep 17 00:00:00 2001 From: Christian Woerz <4927839+chwoerz@users.noreply.github.com> Date: Sat, 12 Oct 2024 10:03:50 +0200 Subject: [PATCH 1/4] the functionality of intrinsic mapping of capitalize and uncapitalize are implemented two times. I made them reusable. --- src/compiler/checker.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 91bbf4d29d3f0..a697fcc1f3fd8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18430,13 +18430,21 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case IntrinsicTypeKind.Lowercase: return str.toLowerCase(); case IntrinsicTypeKind.Capitalize: - return str.charAt(0).toUpperCase() + str.slice(1); + return toCapitalized(str); case IntrinsicTypeKind.Uncapitalize: - return str.charAt(0).toLowerCase() + str.slice(1); + return toUncapitalized(str); } return str; } + function toCapitalized(str: string) { + return str.charAt(0).toUpperCase() + str.slice(1); + } + + function toUncapitalized(str: string) { + return str.charAt(0).toLowerCase() + str.slice(1); + } + function applyTemplateStringMapping(symbol: Symbol, texts: readonly string[], types: readonly Type[]): [texts: readonly string[], types: readonly Type[]] { switch (intrinsicTypeKinds.get(symbol.escapedName as string)) { case IntrinsicTypeKind.Uppercase: @@ -18444,13 +18452,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case IntrinsicTypeKind.Lowercase: return [texts.map(t => t.toLowerCase()), types.map(t => getStringMappingType(symbol, t))]; case IntrinsicTypeKind.Capitalize: - return [texts[0] === "" ? texts : [texts[0].charAt(0).toUpperCase() + texts[0].slice(1), ...texts.slice(1)], texts[0] === "" ? [getStringMappingType(symbol, types[0]), ...types.slice(1)] : types]; + return handleCapitalization(symbol, texts, types, toCapitalized); case IntrinsicTypeKind.Uncapitalize: - return [texts[0] === "" ? texts : [texts[0].charAt(0).toLowerCase() + texts[0].slice(1), ...texts.slice(1)], texts[0] === "" ? [getStringMappingType(symbol, types[0]), ...types.slice(1)] : types]; + return handleCapitalization(symbol, texts, types, toUncapitalized); } return [texts, types]; } + function handleCapitalization(symbol: Symbol, texts: readonly string[], types: readonly Type[], updateFn: (input: string) => string): [texts: readonly string[], types: readonly Type[]] { + return [texts[0] === "" ? texts : [updateFn(texts[0]), ...texts.slice(1)], texts[0] === "" ? [getStringMappingType(symbol, types[0]), ...types.slice(1)] : types]; + } + function getStringMappingTypeForGenericType(symbol: Symbol, type: Type): Type { const id = `${getSymbolId(symbol)},${getTypeId(type)}`; let result = stringMappingTypes.get(id); @@ -34430,7 +34442,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbols === globals) { const primitives = mapDefined( ["string", "number", "boolean", "object", "bigint", "symbol"], - s => symbols.has((s.charAt(0).toUpperCase() + s.slice(1)) as __String) + s => symbols.has((toCapitalized(s)) as __String) ? createSymbol(SymbolFlags.TypeAlias, s as __String) as Symbol : undefined, ); From 95238600b8c67fe9a14fcffb464b178eeb0d7168 Mon Sep 17 00:00:00 2001 From: Christian Woerz <4927839+chwoerz@users.noreply.github.com> Date: Sat, 25 Jan 2025 13:12:50 +0100 Subject: [PATCH 2/4] added a new helper function to match any type --- src/lib/es5.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index ab484e1812e7b..c1f307c39f15c 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1612,7 +1612,7 @@ type NonNullable = T & {}; /** * Obtain the parameters of a function type in a tuple */ -type Parameters any> = T extends (...args: infer P) => any ? P : never; +type Parameters = T extends (...args: infer P) => any ? P : never; /** * Obtain the parameters of a constructor function type in a tuple @@ -1622,7 +1622,7 @@ type ConstructorParameters any> = T ext /** * Obtain the return type of a function type */ -type ReturnType any> = T extends (...args: any) => infer R ? R : any; +type ReturnType = T extends (...args: any) => infer R ? R : any; /** * Obtain the return type of a constructor function type @@ -1654,6 +1654,11 @@ type Uncapitalize = intrinsic; */ type NoInfer = intrinsic; +/** + * A wrapper for a function with any amount of arguments and any return value. + */ +type AnyFunction = (...args: any) => any; + /** * Marker for contextual 'this' type */ From dfd423ead22b7fbd5ec073fbe79a880bc112b655 Mon Sep 17 00:00:00 2001 From: Christian Woerz <4927839+chwoerz@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:05:15 +0100 Subject: [PATCH 3/4] fixed tests --- src/lib/es5.d.ts | 2 +- ...completionsCommitCharactersGlobal.baseline | 350 +++++++++--------- .../constraintWithIndexedAccess.errors.txt | 96 ++--- .../genericRestParameters1.errors.txt | 4 +- ...eyofNestedSimplifiedSubstituteUnwrapped.js | 1 - ...estedSimplifiedSubstituteUnwrapped.symbols | 62 ++-- ...fNestedSimplifiedSubstituteUnwrapped.types | 6 - .../reference/inferTypes1.errors.txt | 8 +- ...antiationExpressionErrorNoCrash.errors.txt | 4 +- .../parameterListAsTupleType.errors.txt | 4 +- ...rtProvider_namespaceSameNameAsIntrinsic.js | 6 + .../pasteEdits_revertUpdatedFile.js | 6 + ...eyofNestedSimplifiedSubstituteUnwrapped.ts | 1 - 13 files changed, 278 insertions(+), 272 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index c1f307c39f15c..7eea944cf43bd 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1657,7 +1657,7 @@ type NoInfer = intrinsic; /** * A wrapper for a function with any amount of arguments and any return value. */ -type AnyFunction = (...args: any) => any; +type AnyFunction = (...args: any[]) => any; /** * Marker for contextual 'this' type diff --git a/tests/baselines/reference/completionsCommitCharactersGlobal.baseline b/tests/baselines/reference/completionsCommitCharactersGlobal.baseline index 582d3363da492..8583f28de140f 100644 --- a/tests/baselines/reference/completionsCommitCharactersGlobal.baseline +++ b/tests/baselines/reference/completionsCommitCharactersGlobal.baseline @@ -2590,6 +2590,7 @@ // | [xyz: number]: boolean; // | } // | any +// | type AnyFunction = (...args: any) => any // | interface Array // | var Array: ArrayConstructor // | interface ArrayBuffer @@ -2690,7 +2691,7 @@ // | type Omit = { [P in Exclude]: T[P]; } // | type OmitThisParameter = unknown extends ThisParameterType ? T : T extends (...args: infer A) => infer R ? (...args: A) => R : T // | type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void -// | type Parameters any> = T extends (...args: infer P) => any ? P : never +// | type Parameters = T extends (...args: infer P) => any ? P : never // | type Partial = { [P in keyof T]?: T[P]; } // | type Pick = { [P in K]: T[P]; } // | interface Promise @@ -2716,7 +2717,7 @@ // | interface RegExpExecArray // | interface RegExpMatchArray // | type Required = { [P in keyof T]-?: T[P]; } -// | type ReturnType any> = T extends (...args: any) => infer R ? R : any +// | type ReturnType = T extends (...args: any) => infer R ? R : any // | string // | interface String // | var String: StringConstructor @@ -2770,6 +2771,7 @@ // | [xyz: number]: boolean; // | } // | any +// | type AnyFunction = (...args: any) => any // | interface Array // | var Array: ArrayConstructor // | interface ArrayBuffer @@ -2870,7 +2872,7 @@ // | type Omit = { [P in Exclude]: T[P]; } // | type OmitThisParameter = unknown extends ThisParameterType ? T : T extends (...args: infer A) => infer R ? (...args: A) => R : T // | type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void -// | type Parameters any> = T extends (...args: infer P) => any ? P : never +// | type Parameters = T extends (...args: infer P) => any ? P : never // | type Partial = { [P in keyof T]?: T[P]; } // | type Pick = { [P in K]: T[P]; } // | interface Promise @@ -2896,7 +2898,7 @@ // | interface RegExpExecArray // | interface RegExpMatchArray // | type Required = { [P in keyof T]-?: T[P]; } -// | type ReturnType any> = T extends (...args: any) => infer R ? R : any +// | type ReturnType = T extends (...args: any) => infer R ? R : any // | string // | interface String // | var String: StringConstructor @@ -74347,6 +74349,88 @@ } ] }, + { + "name": "AnyFunction", + "kind": "type", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "AnyFunction", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "...", + "kind": "punctuation" + }, + { + "text": "args", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "A wrapper for a function with any amount of arguments and any return value.", + "kind": "text" + } + ] + }, { "name": "Array", "kind": "var", @@ -80309,48 +80393,8 @@ "kind": "space" }, { - "text": "(", - "kind": "punctuation" - }, - { - "text": "...", - "kind": "punctuation" - }, - { - "text": "args", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" + "text": "AnyFunction", + "kind": "aliasName" }, { "text": ">", @@ -82090,48 +82134,8 @@ "kind": "space" }, { - "text": "(", - "kind": "punctuation" - }, - { - "text": "...", - "kind": "punctuation" - }, - { - "text": "args", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" + "text": "AnyFunction", + "kind": "aliasName" }, { "text": ">", @@ -83818,6 +83822,88 @@ } ] }, + { + "name": "AnyFunction", + "kind": "type", + "kindModifiers": "declare", + "sortText": "15", + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "AnyFunction", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "...", + "kind": "punctuation" + }, + { + "text": "args", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "A wrapper for a function with any amount of arguments and any return value.", + "kind": "text" + } + ] + }, { "name": "Array", "kind": "var", @@ -89780,48 +89866,8 @@ "kind": "space" }, { - "text": "(", - "kind": "punctuation" - }, - { - "text": "...", - "kind": "punctuation" - }, - { - "text": "args", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" + "text": "AnyFunction", + "kind": "aliasName" }, { "text": ">", @@ -91561,48 +91607,8 @@ "kind": "space" }, { - "text": "(", - "kind": "punctuation" - }, - { - "text": "...", - "kind": "punctuation" - }, - { - "text": "args", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "=>", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" + "text": "AnyFunction", + "kind": "aliasName" }, { "text": ">", diff --git a/tests/baselines/reference/constraintWithIndexedAccess.errors.txt b/tests/baselines/reference/constraintWithIndexedAccess.errors.txt index 11641a24b4fce..b3e26bf1cc1e2 100644 --- a/tests/baselines/reference/constraintWithIndexedAccess.errors.txt +++ b/tests/baselines/reference/constraintWithIndexedAccess.errors.txt @@ -1,29 +1,29 @@ -constraintWithIndexedAccess.ts(23,90): error TS2344: Type 'TypeHardcodedAsParameterWithoutReturnType' does not satisfy the constraint '(...args: any) => any'. - Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[T][string]' is not assignable to type '(...args: any) => any'. -constraintWithIndexedAccess.ts(24,102): error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint '(...args: any) => any'. - Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[T][string]' is not assignable to type '(...args: any) => any'. -constraintWithIndexedAccess.ts(26,103): error TS2344: Type 'VehicleSelector[F]' does not satisfy the constraint '(...args: any) => any'. - Type 'VehicleSelector[keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. - Type 'VehicleSelector[string] | VehicleSelector[number] | VehicleSelector[symbol]' is not assignable to type '(...args: any) => any'. - Type 'VehicleSelector[string]' is not assignable to type '(...args: any) => any'. -constraintWithIndexedAccess.ts(27,102): error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint '(...args: any) => any'. - Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[T][string]' is not assignable to type '(...args: any) => any'. -constraintWithIndexedAccess.ts(28,102): error TS2344: Type 'DataFetchFns[T][T]' does not satisfy the constraint '(...args: any) => any'. - Type 'DataFetchFns[T]["Boat"] | DataFetchFns[T]["Plane"]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[T]["Boat"]' is not assignable to type '(...args: any) => any'. +constraintWithIndexedAccess.ts(23,90): error TS2344: Type 'TypeHardcodedAsParameterWithoutReturnType' does not satisfy the constraint 'AnyFunction'. + Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[T][string]' is not assignable to type 'AnyFunction'. +constraintWithIndexedAccess.ts(24,102): error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint 'AnyFunction'. + Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[T][string]' is not assignable to type 'AnyFunction'. +constraintWithIndexedAccess.ts(26,103): error TS2344: Type 'VehicleSelector[F]' does not satisfy the constraint 'AnyFunction'. + Type 'VehicleSelector[keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. + Type 'VehicleSelector[string] | VehicleSelector[number] | VehicleSelector[symbol]' is not assignable to type 'AnyFunction'. + Type 'VehicleSelector[string]' is not assignable to type 'AnyFunction'. +constraintWithIndexedAccess.ts(27,102): error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint 'AnyFunction'. + Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[T][string]' is not assignable to type 'AnyFunction'. +constraintWithIndexedAccess.ts(28,102): error TS2344: Type 'DataFetchFns[T][T]' does not satisfy the constraint 'AnyFunction'. + Type 'DataFetchFns[T]["Boat"] | DataFetchFns[T]["Plane"]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[T]["Boat"]' is not assignable to type 'AnyFunction'. constraintWithIndexedAccess.ts(28,102): error TS2536: Type 'T' cannot be used to index type 'DataFetchFns[T]'. constraintWithIndexedAccess.ts(29,102): error TS2536: Type 'F' cannot be used to index type 'DataFetchFns'. -constraintWithIndexedAccess.ts(29,102): error TS2344: Type 'DataFetchFns[F][F]' does not satisfy the constraint '(...args: any) => any'. - Type 'DataFetchFns[F][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[F][string] | DataFetchFns[F][number] | DataFetchFns[F][symbol]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[F][string]' is not assignable to type '(...args: any) => any'. - Type 'DataFetchFns[keyof DataFetchFns[T]][string]' is not assignable to type '(...args: any) => any'. +constraintWithIndexedAccess.ts(29,102): error TS2344: Type 'DataFetchFns[F][F]' does not satisfy the constraint 'AnyFunction'. + Type 'DataFetchFns[F][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[F][string] | DataFetchFns[F][number] | DataFetchFns[F][symbol]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[F][string]' is not assignable to type 'AnyFunction'. + Type 'DataFetchFns[keyof DataFetchFns[T]][string]' is not assignable to type 'AnyFunction'. constraintWithIndexedAccess.ts(29,102): error TS2536: Type 'F' cannot be used to index type 'DataFetchFns[F]'. @@ -52,45 +52,45 @@ constraintWithIndexedAccess.ts(29,102): error TS2536: Type 'F' cannot be used to export type SucceedingCombo = ReturnType>; export type FailingCombo = ReturnType>; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'TypeHardcodedAsParameterWithoutReturnType' does not satisfy the constraint '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][string]' is not assignable to type '(...args: any) => any'. +!!! error TS2344: Type 'TypeHardcodedAsParameterWithoutReturnType' does not satisfy the constraint 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][string]' is not assignable to type 'AnyFunction'. export type TypeHardcodedAsParameter = ReturnType; ~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][string]' is not assignable to type '(...args: any) => any'. +!!! error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][string]' is not assignable to type 'AnyFunction'. type VehicleSelector = DataFetchFns[T]; export type TypeHardcodedAsParameter2 = ReturnType[F]>; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'VehicleSelector[F]' does not satisfy the constraint '(...args: any) => any'. -!!! error TS2344: Type 'VehicleSelector[keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'VehicleSelector[string] | VehicleSelector[number] | VehicleSelector[symbol]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'VehicleSelector[string]' is not assignable to type '(...args: any) => any'. +!!! error TS2344: Type 'VehicleSelector[F]' does not satisfy the constraint 'AnyFunction'. +!!! error TS2344: Type 'VehicleSelector[keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'VehicleSelector[string] | VehicleSelector[number] | VehicleSelector[symbol]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'VehicleSelector[string]' is not assignable to type 'AnyFunction'. export type TypeGeneric1 = ReturnType; ~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T][string]' is not assignable to type '(...args: any) => any'. +!!! error TS2344: Type 'DataFetchFns[T][F]' does not satisfy the constraint 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][string] | DataFetchFns[T][number] | DataFetchFns[T][symbol]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T][string]' is not assignable to type 'AnyFunction'. export type TypeGeneric2 = ReturnType; // error ~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'DataFetchFns[T][T]' does not satisfy the constraint '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T]["Boat"] | DataFetchFns[T]["Plane"]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[T]["Boat"]' is not assignable to type '(...args: any) => any'. +!!! error TS2344: Type 'DataFetchFns[T][T]' does not satisfy the constraint 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T]["Boat"] | DataFetchFns[T]["Plane"]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[T]["Boat"]' is not assignable to type 'AnyFunction'. ~~~~~~~~~~~~~~~~~~ !!! error TS2536: Type 'T' cannot be used to index type 'DataFetchFns[T]'. export type TypeGeneric3 = ReturnType; // error ~~~~~~~~~~~~~~~ !!! error TS2536: Type 'F' cannot be used to index type 'DataFetchFns'. ~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'DataFetchFns[F][F]' does not satisfy the constraint '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[F][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[F][string] | DataFetchFns[F][number] | DataFetchFns[F][symbol]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[F][string]' is not assignable to type '(...args: any) => any'. -!!! error TS2344: Type 'DataFetchFns[keyof DataFetchFns[T]][string]' is not assignable to type '(...args: any) => any'. +!!! error TS2344: Type 'DataFetchFns[F][F]' does not satisfy the constraint 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[F][keyof DataFetchFns[T]]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[F][string] | DataFetchFns[F][number] | DataFetchFns[F][symbol]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[F][string]' is not assignable to type 'AnyFunction'. +!!! error TS2344: Type 'DataFetchFns[keyof DataFetchFns[T]][string]' is not assignable to type 'AnyFunction'. ~~~~~~~~~~~~~~~~~~ !!! error TS2536: Type 'F' cannot be used to index type 'DataFetchFns[F]'. \ No newline at end of file diff --git a/tests/baselines/reference/genericRestParameters1.errors.txt b/tests/baselines/reference/genericRestParameters1.errors.txt index 99511d08c2daf..03f74d2c2cbf5 100644 --- a/tests/baselines/reference/genericRestParameters1.errors.txt +++ b/tests/baselines/reference/genericRestParameters1.errors.txt @@ -1,4 +1,4 @@ -genericRestParameters1.ts(135,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'. +genericRestParameters1.ts(135,23): error TS2344: Type 'Function' does not satisfy the constraint 'AnyFunction'. Type 'Function' provides no match for the signature '(...args: any): any'. genericRestParameters1.ts(164,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'. Types of parameters 'a' and 'args' are incompatible. @@ -142,7 +142,7 @@ genericRestParameters1.ts(164,1): error TS2322: Type '(a: never) => void' is not type T08 = ConstructorParameters void>; type T09 = Parameters; ~~~~~~~~ -!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'. +!!! error TS2344: Type 'Function' does not satisfy the constraint 'AnyFunction'. !!! error TS2344: Type 'Function' provides no match for the signature '(...args: any): any'. type Record1 = { diff --git a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js index a8b1688d633c3..81897092a122f 100644 --- a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js +++ b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.js @@ -1,7 +1,6 @@ //// [tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts] //// //// [indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts] -type AnyFunction = (...args: any[]) => any; type Params = Parameters>; interface Wrapper { diff --git a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.symbols b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.symbols index 6b5e4281af3ff..7188c109beb7e 100644 --- a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.symbols +++ b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.symbols @@ -1,64 +1,60 @@ //// [tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts] //// === indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts === -type AnyFunction = (...args: any[]) => any; ->AnyFunction : Symbol(AnyFunction, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 0)) ->args : Symbol(args, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 20)) - type Params = Parameters>; ->Params : Symbol(Params, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 43)) ->T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 12)) +>Params : Symbol(Params, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 0)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 12)) >Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 12)) ->AnyFunction : Symbol(AnyFunction, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 0)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 12)) +>AnyFunction : Symbol(AnyFunction, Decl(lib.es5.d.ts, --, --)) interface Wrapper { ->Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 53)) ->T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 18)) +>Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 53)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 2, 18)) call(event: K, ...args: Params): void; ->call : Symbol(Wrapper.call, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 22)) ->K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 6)) ->T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 18)) ->event : Symbol(event, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 25)) ->K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 6)) ->args : Symbol(args, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 34)) ->Params : Symbol(Params, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 43)) ->T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 18)) ->K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 6)) +>call : Symbol(Wrapper.call, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 2, 22)) +>K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 6)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 2, 18)) +>event : Symbol(event, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 25)) +>K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 6)) +>args : Symbol(args, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 34)) +>Params : Symbol(Params, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 0)) +>T : Symbol(T, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 2, 18)) +>K : Symbol(K, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 3, 6)) } interface AWrapped { ->AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 5, 1)) +>AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 1)) foo(): void; ->foo : Symbol(AWrapped.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 7, 20)) +>foo : Symbol(AWrapped.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 6, 20)) } class A { ->A : Symbol(A, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 9, 1)) +>A : Symbol(A, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 8, 1)) foo: Wrapper; ->foo : Symbol(A.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 11, 9)) ->Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 53)) ->AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 5, 1)) +>foo : Symbol(A.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 10, 9)) +>Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 53)) +>AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 1)) } interface BWrapped extends AWrapped { ->BWrapped : Symbol(BWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 13, 1)) ->AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 5, 1)) +>BWrapped : Symbol(BWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 12, 1)) +>AWrapped : Symbol(AWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 4, 1)) bar(): void; ->bar : Symbol(BWrapped.bar, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 15, 37)) +>bar : Symbol(BWrapped.bar, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 14, 37)) } class B extends A { ->B : Symbol(B, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 17, 1)) ->A : Symbol(A, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 9, 1)) +>B : Symbol(B, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 16, 1)) +>A : Symbol(A, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 8, 1)) foo: Wrapper; ->foo : Symbol(B.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 19, 19)) ->Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 1, 53)) ->BWrapped : Symbol(BWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 13, 1)) +>foo : Symbol(B.foo, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 18, 19)) +>Wrapper : Symbol(Wrapper, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 0, 53)) +>BWrapped : Symbol(BWrapped, Decl(indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts, 12, 1)) } diff --git a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types index 96b4f67f41db9..a5142d64e2c8f 100644 --- a/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types +++ b/tests/baselines/reference/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.types @@ -1,12 +1,6 @@ //// [tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts] //// === indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts === -type AnyFunction = (...args: any[]) => any; ->AnyFunction : AnyFunction -> : ^^^^^^^^^^^ ->args : any[] -> : ^^^^^ - type Params = Parameters>; >Params : Params > : ^^^^^^^^^ diff --git a/tests/baselines/reference/inferTypes1.errors.txt b/tests/baselines/reference/inferTypes1.errors.txt index a5d4c73aaa388..9e3b08602e4df 100644 --- a/tests/baselines/reference/inferTypes1.errors.txt +++ b/tests/baselines/reference/inferTypes1.errors.txt @@ -1,5 +1,5 @@ -inferTypes1.ts(36,23): error TS2344: Type 'string' does not satisfy the constraint '(...args: any) => any'. -inferTypes1.ts(37,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'. +inferTypes1.ts(36,23): error TS2344: Type 'string' does not satisfy the constraint 'AnyFunction'. +inferTypes1.ts(37,23): error TS2344: Type 'Function' does not satisfy the constraint 'AnyFunction'. Type 'Function' provides no match for the signature '(...args: any): any'. inferTypes1.ts(43,25): error TS2344: Type 'string' does not satisfy the constraint 'abstract new (...args: any) => any'. inferTypes1.ts(44,25): error TS2344: Type 'Function' does not satisfy the constraint 'abstract new (...args: any) => any'. @@ -57,10 +57,10 @@ inferTypes1.ts(153,40): error TS2322: Type 'T' is not assignable to type 'string type T16 = ReturnType; // never type T17 = ReturnType; // Error ~~~~~~ -!!! error TS2344: Type 'string' does not satisfy the constraint '(...args: any) => any'. +!!! error TS2344: Type 'string' does not satisfy the constraint 'AnyFunction'. type T18 = ReturnType; // Error ~~~~~~~~ -!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any) => any'. +!!! error TS2344: Type 'Function' does not satisfy the constraint 'AnyFunction'. !!! error TS2344: Type 'Function' provides no match for the signature '(...args: any): any'. type T19 = ReturnType<(x: string, ...args: T) => T[]>; // T[] diff --git a/tests/baselines/reference/instantiationExpressionErrorNoCrash.errors.txt b/tests/baselines/reference/instantiationExpressionErrorNoCrash.errors.txt index 58ae63d76c5b7..52ba405081889 100644 --- a/tests/baselines/reference/instantiationExpressionErrorNoCrash.errors.txt +++ b/tests/baselines/reference/instantiationExpressionErrorNoCrash.errors.txt @@ -1,4 +1,4 @@ -instantiationExpressionErrorNoCrash.ts(15,38): error TS2344: Type 'typeof createCacheReducer' does not satisfy the constraint '(...args: any) => any'. +instantiationExpressionErrorNoCrash.ts(15,38): error TS2344: Type 'typeof createCacheReducer' does not satisfy the constraint 'AnyFunction'. Type 'typeof createCacheReducer' provides no match for the signature '(...args: any): any'. instantiationExpressionErrorNoCrash.ts(15,64): error TS2635: Type '(queries: { [QK in keyof QR]: any; }) => (state?: { queries: QR; }) => { queries: QR; }' has no signatures for which the type argument list is applicable. @@ -20,7 +20,7 @@ instantiationExpressionErrorNoCrash.ts(15,64): error TS2635: Type '>; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2344: Type 'typeof createCacheReducer' does not satisfy the constraint '(...args: any) => any'. +!!! error TS2344: Type 'typeof createCacheReducer' does not satisfy the constraint 'AnyFunction'. !!! error TS2344: Type 'typeof createCacheReducer' provides no match for the signature '(...args: any): any'. ~~ !!! error TS2635: Type '(queries: { [QK in keyof QR]: any; }) => (state?: { queries: QR; }) => { queries: QR; }' has no signatures for which the type argument list is applicable. diff --git a/tests/baselines/reference/parameterListAsTupleType.errors.txt b/tests/baselines/reference/parameterListAsTupleType.errors.txt index 51502b8131e8d..1249bf8cf609d 100644 --- a/tests/baselines/reference/parameterListAsTupleType.errors.txt +++ b/tests/baselines/reference/parameterListAsTupleType.errors.txt @@ -1,5 +1,5 @@ parameterListAsTupleType.ts(8,17): error TS2322: Type 'string' is not assignable to type 'number'. -parameterListAsTupleType.ts(16,23): error TS2344: Type 'typeof C' does not satisfy the constraint '(...args: any) => any'. +parameterListAsTupleType.ts(16,23): error TS2344: Type 'typeof C' does not satisfy the constraint 'AnyFunction'. Type 'typeof C' provides no match for the signature '(...args: any): any'. @@ -23,7 +23,7 @@ parameterListAsTupleType.ts(16,23): error TS2344: Type 'typeof C' does not satis type Cps = Parameters; // should not work ~~~~~~~~ -!!! error TS2344: Type 'typeof C' does not satisfy the constraint '(...args: any) => any'. +!!! error TS2344: Type 'typeof C' does not satisfy the constraint 'AnyFunction'. !!! error TS2344: Type 'typeof C' provides no match for the signature '(...args: any): any'. type Ccps = ConstructorParameters; // should be [number, string] diff --git a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js index 5a4e9f3db3c0d..3bea1b448f484 100644 --- a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js +++ b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_namespaceSameNameAsIntrinsic.js @@ -478,6 +478,12 @@ Info seq [hh:mm:ss:mss] response: "kindModifiers": "", "sortText": "15" }, + { + "name": "AnyFunction", + "kind": "type", + "kindModifiers": "declare", + "sortText": "15" + }, { "name": "Array", "kind": "var", diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_revertUpdatedFile.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_revertUpdatedFile.js index f0d22e519baee..9b65f4420192e 100644 --- a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_revertUpdatedFile.js +++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_revertUpdatedFile.js @@ -424,6 +424,12 @@ Info seq [hh:mm:ss:mss] response: "kindModifiers": "", "sortText": "15" }, + { + "name": "AnyFunction", + "kind": "type", + "kindModifiers": "declare", + "sortText": "15" + }, { "name": "Array", "kind": "var", diff --git a/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts b/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts index a68ea9beee6d2..d7ea09f0b6260 100644 --- a/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts +++ b/tests/cases/compiler/indexedAccessKeyofNestedSimplifiedSubstituteUnwrapped.ts @@ -1,4 +1,3 @@ -type AnyFunction = (...args: any[]) => any; type Params = Parameters>; interface Wrapper { From d3c8cbc1e5559ed1fc3abf9612c75b9110d7b955 Mon Sep 17 00:00:00 2001 From: Christian Woerz <4927839+chwoerz@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:11:01 +0100 Subject: [PATCH 4/4] removed unwanted change --- src/compiler/checker.ts | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a697fcc1f3fd8..91bbf4d29d3f0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18430,21 +18430,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case IntrinsicTypeKind.Lowercase: return str.toLowerCase(); case IntrinsicTypeKind.Capitalize: - return toCapitalized(str); + return str.charAt(0).toUpperCase() + str.slice(1); case IntrinsicTypeKind.Uncapitalize: - return toUncapitalized(str); + return str.charAt(0).toLowerCase() + str.slice(1); } return str; } - function toCapitalized(str: string) { - return str.charAt(0).toUpperCase() + str.slice(1); - } - - function toUncapitalized(str: string) { - return str.charAt(0).toLowerCase() + str.slice(1); - } - function applyTemplateStringMapping(symbol: Symbol, texts: readonly string[], types: readonly Type[]): [texts: readonly string[], types: readonly Type[]] { switch (intrinsicTypeKinds.get(symbol.escapedName as string)) { case IntrinsicTypeKind.Uppercase: @@ -18452,17 +18444,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case IntrinsicTypeKind.Lowercase: return [texts.map(t => t.toLowerCase()), types.map(t => getStringMappingType(symbol, t))]; case IntrinsicTypeKind.Capitalize: - return handleCapitalization(symbol, texts, types, toCapitalized); + return [texts[0] === "" ? texts : [texts[0].charAt(0).toUpperCase() + texts[0].slice(1), ...texts.slice(1)], texts[0] === "" ? [getStringMappingType(symbol, types[0]), ...types.slice(1)] : types]; case IntrinsicTypeKind.Uncapitalize: - return handleCapitalization(symbol, texts, types, toUncapitalized); + return [texts[0] === "" ? texts : [texts[0].charAt(0).toLowerCase() + texts[0].slice(1), ...texts.slice(1)], texts[0] === "" ? [getStringMappingType(symbol, types[0]), ...types.slice(1)] : types]; } return [texts, types]; } - function handleCapitalization(symbol: Symbol, texts: readonly string[], types: readonly Type[], updateFn: (input: string) => string): [texts: readonly string[], types: readonly Type[]] { - return [texts[0] === "" ? texts : [updateFn(texts[0]), ...texts.slice(1)], texts[0] === "" ? [getStringMappingType(symbol, types[0]), ...types.slice(1)] : types]; - } - function getStringMappingTypeForGenericType(symbol: Symbol, type: Type): Type { const id = `${getSymbolId(symbol)},${getTypeId(type)}`; let result = stringMappingTypes.get(id); @@ -34442,7 +34430,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbols === globals) { const primitives = mapDefined( ["string", "number", "boolean", "object", "bigint", "symbol"], - s => symbols.has((toCapitalized(s)) as __String) + s => symbols.has((s.charAt(0).toUpperCase() + s.slice(1)) as __String) ? createSymbol(SymbolFlags.TypeAlias, s as __String) as Symbol : undefined, );