1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
=== tests/cases/compiler/constraintWithIndexedAccess.ts ===
// #52399
type DataFetchFns = {
>DataFetchFns : { Boat: { requiresLicense: (id: string) => boolean; maxGroundSpeed: (id: string) => number; description: (id: string) => string; displacement: (id: string) => number; name: (id: string) => string; }; Plane: { requiresLicense: (id: string) => boolean; maxGroundSpeed: (id: string) => number; maxTakeoffWeight: (id: string) => number; maxCruisingAltitude: (id: string) => number; name: (id: string) => string; }; }
Boat: {
>Boat : { requiresLicense: (id: string) => boolean; maxGroundSpeed: (id: string) => number; description: (id: string) => string; displacement: (id: string) => number; name: (id: string) => string; }
requiresLicense: (id: string) => boolean;
>requiresLicense : (id: string) => boolean
>id : string
maxGroundSpeed: (id: string) => number;
>maxGroundSpeed : (id: string) => number
>id : string
description: (id: string) => string;
>description : (id: string) => string
>id : string
displacement: (id: string) => number;
>displacement : (id: string) => number
>id : string
name: (id: string) => string;
>name : (id: string) => string
>id : string
};
Plane: {
>Plane : { requiresLicense: (id: string) => boolean; maxGroundSpeed: (id: string) => number; maxTakeoffWeight: (id: string) => number; maxCruisingAltitude: (id: string) => number; name: (id: string) => string; }
requiresLicense: (id: string) => boolean;
>requiresLicense : (id: string) => boolean
>id : string
maxGroundSpeed: (id: string) => number;
>maxGroundSpeed : (id: string) => number
>id : string
maxTakeoffWeight: (id: string) => number;
>maxTakeoffWeight : (id: string) => number
>id : string
maxCruisingAltitude: (id: string) => number;
>maxCruisingAltitude : (id: string) => number
>id : string
name: (id: string) => string;
>name : (id: string) => string
>id : string
}
}
export type NoTypeParamBoatRequired<F extends keyof DataFetchFns['Boat']> = ReturnType<DataFetchFns['Boat'][F]>;
>NoTypeParamBoatRequired : NoTypeParamBoatRequired<F>
type TypeHardcodedAsParameterWithoutReturnType<T extends 'Boat', F extends keyof DataFetchFns[T]> = DataFetchFns[T][F];
>TypeHardcodedAsParameterWithoutReturnType : TypeHardcodedAsParameterWithoutReturnType<T, F>
export type allAreFunctionsAsExpected = TypeHardcodedAsParameterWithoutReturnType<'Boat', keyof DataFetchFns['Boat']>;
>allAreFunctionsAsExpected : ((id: string) => boolean) | ((id: string) => number) | ((id: string) => string) | ((id: string) => number) | ((id: string) => string)
export type returnTypeOfFunctions = ReturnType<allAreFunctionsAsExpected>; //string | number | boolean as expected
>returnTypeOfFunctions : string | number | boolean
export type SucceedingCombo = ReturnType<TypeHardcodedAsParameterWithoutReturnType<'Boat', keyof DataFetchFns['Boat']>>;
>SucceedingCombo : string | number | boolean
export type FailingCombo<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<TypeHardcodedAsParameterWithoutReturnType<T,F>>;
>FailingCombo : FailingCombo<T, F>
export type TypeHardcodedAsParameter<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][F]>;
>TypeHardcodedAsParameter : TypeHardcodedAsParameter<T, F>
type VehicleSelector<T extends keyof DataFetchFns> = DataFetchFns[T];
>VehicleSelector : VehicleSelector<T>
export type TypeHardcodedAsParameter2<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<VehicleSelector<T>[F]>;
>TypeHardcodedAsParameter2 : TypeHardcodedAsParameter2<T, F>
export type TypeGeneric1<T extends keyof DataFetchFns, F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][F]>;
>TypeGeneric1 : TypeGeneric1<T, F>
export type TypeGeneric2<T extends keyof DataFetchFns, F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][T]>; // error
>TypeGeneric2 : TypeGeneric2<T, F>
export type TypeGeneric3<T extends keyof DataFetchFns, F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[F][F]>; // error
>TypeGeneric3 : TypeGeneric3<T, F>
|