|
| 1 | +tests/cases/compiler/constraintWithIndexedAccess.ts(27,13): error TS2300: Duplicate identifier 'TypeGeneric'. |
| 2 | +tests/cases/compiler/constraintWithIndexedAccess.ts(28,13): error TS2300: Duplicate identifier 'TypeGeneric'. |
| 3 | +tests/cases/compiler/constraintWithIndexedAccess.ts(28,101): error TS2344: Type 'DataFetchFns[T][T]' does not satisfy the constraint '(...args: any) => any'. |
| 4 | + Type 'DataFetchFns[T]["Boat"] | DataFetchFns[T]["Plane"]' is not assignable to type '(...args: any) => any'. |
| 5 | + Type 'DataFetchFns[T]["Boat"]' is not assignable to type '(...args: any) => any'. |
| 6 | +tests/cases/compiler/constraintWithIndexedAccess.ts(28,101): error TS2536: Type 'T' cannot be used to index type 'DataFetchFns[T]'. |
| 7 | +tests/cases/compiler/constraintWithIndexedAccess.ts(29,13): error TS2300: Duplicate identifier 'TypeGeneric'. |
| 8 | +tests/cases/compiler/constraintWithIndexedAccess.ts(29,101): error TS2536: Type 'F' cannot be used to index type 'DataFetchFns'. |
| 9 | +tests/cases/compiler/constraintWithIndexedAccess.ts(29,101): error TS2344: Type 'DataFetchFns[F][F]' does not satisfy the constraint '(...args: any) => any'. |
| 10 | + Type 'DataFetchFns[F][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. |
| 11 | + Type 'DataFetchFns[F][string] | DataFetchFns[F][number] | DataFetchFns[F][symbol]' is not assignable to type '(...args: any) => any'. |
| 12 | + Type 'DataFetchFns[F][string]' is not assignable to type '(...args: any) => any'. |
| 13 | + Type 'DataFetchFns[keyof DataFetchFns[T]][string]' is not assignable to type '(...args: any) => any'. |
| 14 | +tests/cases/compiler/constraintWithIndexedAccess.ts(29,101): error TS2536: Type 'F' cannot be used to index type 'DataFetchFns[F]'. |
| 15 | + |
| 16 | + |
| 17 | +==== tests/cases/compiler/constraintWithIndexedAccess.ts (8 errors) ==== |
| 18 | + // #52399 |
| 19 | + type DataFetchFns = { |
| 20 | + Boat: { |
| 21 | + requiresLicense: (id: string) => boolean; |
| 22 | + maxGroundSpeed: (id: string) => number; |
| 23 | + description: (id: string) => string; |
| 24 | + displacement: (id: string) => number; |
| 25 | + name: (id: string) => string; |
| 26 | + }; |
| 27 | + Plane: { |
| 28 | + requiresLicense: (id: string) => boolean; |
| 29 | + maxGroundSpeed: (id: string) => number; |
| 30 | + maxTakeoffWeight: (id: string) => number; |
| 31 | + maxCruisingAltitude: (id: string) => number; |
| 32 | + name: (id: string) => string; |
| 33 | + } |
| 34 | + } |
| 35 | + export type NoTypeParamBoatRequired<F extends keyof DataFetchFns['Boat']> = ReturnType<DataFetchFns['Boat'][F]>; |
| 36 | + type TypeHardcodedAsParameterWithoutReturnType<T extends 'Boat', F extends keyof DataFetchFns[T]> = DataFetchFns[T][F]; |
| 37 | + export type allAreFunctionsAsExpected = TypeHardcodedAsParameterWithoutReturnType<'Boat', keyof DataFetchFns['Boat']>; |
| 38 | + export type returnTypeOfFunctions = ReturnType<allAreFunctionsAsExpected>; //string | number | boolean as expected |
| 39 | + export type SucceedingCombo = ReturnType<TypeHardcodedAsParameterWithoutReturnType<'Boat', keyof DataFetchFns['Boat']>>; |
| 40 | + export type FailingCombo<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<TypeHardcodedAsParameterWithoutReturnType<T,F>>; |
| 41 | + export type TypeHardcodedAsParameter<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][F]>; |
| 42 | + type VehicleSelector<T extends keyof DataFetchFns> = DataFetchFns[T]; |
| 43 | + export type TypeHardcodedAsParameter2<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<VehicleSelector<T>[F]>; |
| 44 | + export type TypeGeneric<T extends keyof DataFetchFns, F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][F]>; |
| 45 | + ~~~~~~~~~~~ |
| 46 | +!!! error TS2300: Duplicate identifier 'TypeGeneric'. |
| 47 | + export type TypeGeneric<T extends keyof DataFetchFns, F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][T]>; // error |
| 48 | + ~~~~~~~~~~~ |
| 49 | +!!! error TS2300: Duplicate identifier 'TypeGeneric'. |
| 50 | + ~~~~~~~~~~~~~~~~~~ |
| 51 | +!!! error TS2344: Type 'DataFetchFns[T][T]' does not satisfy the constraint '(...args: any) => any'. |
| 52 | +!!! error TS2344: Type 'DataFetchFns[T]["Boat"] | DataFetchFns[T]["Plane"]' is not assignable to type '(...args: any) => any'. |
| 53 | +!!! error TS2344: Type 'DataFetchFns[T]["Boat"]' is not assignable to type '(...args: any) => any'. |
| 54 | + ~~~~~~~~~~~~~~~~~~ |
| 55 | +!!! error TS2536: Type 'T' cannot be used to index type 'DataFetchFns[T]'. |
| 56 | + export type TypeGeneric<T extends keyof DataFetchFns, F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[F][F]>; // error |
| 57 | + ~~~~~~~~~~~ |
| 58 | +!!! error TS2300: Duplicate identifier 'TypeGeneric'. |
| 59 | + ~~~~~~~~~~~~~~~ |
| 60 | +!!! error TS2536: Type 'F' cannot be used to index type 'DataFetchFns'. |
| 61 | + ~~~~~~~~~~~~~~~~~~ |
| 62 | +!!! error TS2344: Type 'DataFetchFns[F][F]' does not satisfy the constraint '(...args: any) => any'. |
| 63 | +!!! error TS2344: Type 'DataFetchFns[F][keyof DataFetchFns[T]]' is not assignable to type '(...args: any) => any'. |
| 64 | +!!! error TS2344: Type 'DataFetchFns[F][string] | DataFetchFns[F][number] | DataFetchFns[F][symbol]' is not assignable to type '(...args: any) => any'. |
| 65 | +!!! error TS2344: Type 'DataFetchFns[F][string]' is not assignable to type '(...args: any) => any'. |
| 66 | +!!! error TS2344: Type 'DataFetchFns[keyof DataFetchFns[T]][string]' is not assignable to type '(...args: any) => any'. |
| 67 | + ~~~~~~~~~~~~~~~~~~ |
| 68 | +!!! error TS2536: Type 'F' cannot be used to index type 'DataFetchFns[F]'. |
| 69 | + |
0 commit comments