|
| 1 | +=== tests/cases/compiler/constraintWithIndexedAccess.ts === |
| 2 | +// #52399 |
| 3 | +type DataFetchFns = { |
| 4 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 5 | + |
| 6 | + Boat: { |
| 7 | +>Boat : Symbol(Boat, Decl(constraintWithIndexedAccess.ts, 1, 21)) |
| 8 | + |
| 9 | + requiresLicense: (id: string) => boolean; |
| 10 | +>requiresLicense : Symbol(requiresLicense, Decl(constraintWithIndexedAccess.ts, 2, 11)) |
| 11 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 3, 26)) |
| 12 | + |
| 13 | + maxGroundSpeed: (id: string) => number; |
| 14 | +>maxGroundSpeed : Symbol(maxGroundSpeed, Decl(constraintWithIndexedAccess.ts, 3, 49)) |
| 15 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 4, 25)) |
| 16 | + |
| 17 | + description: (id: string) => string; |
| 18 | +>description : Symbol(description, Decl(constraintWithIndexedAccess.ts, 4, 47)) |
| 19 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 5, 22)) |
| 20 | + |
| 21 | + displacement: (id: string) => number; |
| 22 | +>displacement : Symbol(displacement, Decl(constraintWithIndexedAccess.ts, 5, 44)) |
| 23 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 6, 23)) |
| 24 | + |
| 25 | + name: (id: string) => string; |
| 26 | +>name : Symbol(name, Decl(constraintWithIndexedAccess.ts, 6, 45)) |
| 27 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 7, 15)) |
| 28 | + |
| 29 | + }; |
| 30 | + Plane: { |
| 31 | +>Plane : Symbol(Plane, Decl(constraintWithIndexedAccess.ts, 8, 6)) |
| 32 | + |
| 33 | + requiresLicense: (id: string) => boolean; |
| 34 | +>requiresLicense : Symbol(requiresLicense, Decl(constraintWithIndexedAccess.ts, 9, 12)) |
| 35 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 10, 26)) |
| 36 | + |
| 37 | + maxGroundSpeed: (id: string) => number; |
| 38 | +>maxGroundSpeed : Symbol(maxGroundSpeed, Decl(constraintWithIndexedAccess.ts, 10, 49)) |
| 39 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 11, 25)) |
| 40 | + |
| 41 | + maxTakeoffWeight: (id: string) => number; |
| 42 | +>maxTakeoffWeight : Symbol(maxTakeoffWeight, Decl(constraintWithIndexedAccess.ts, 11, 47)) |
| 43 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 12, 27)) |
| 44 | + |
| 45 | + maxCruisingAltitude: (id: string) => number; |
| 46 | +>maxCruisingAltitude : Symbol(maxCruisingAltitude, Decl(constraintWithIndexedAccess.ts, 12, 49)) |
| 47 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 13, 30)) |
| 48 | + |
| 49 | + name: (id: string) => string; |
| 50 | +>name : Symbol(name, Decl(constraintWithIndexedAccess.ts, 13, 52)) |
| 51 | +>id : Symbol(id, Decl(constraintWithIndexedAccess.ts, 14, 15)) |
| 52 | + } |
| 53 | +} |
| 54 | +export type NoTypeParamBoatRequired<F extends keyof DataFetchFns['Boat']> = ReturnType<DataFetchFns['Boat'][F]>; |
| 55 | +>NoTypeParamBoatRequired : Symbol(NoTypeParamBoatRequired, Decl(constraintWithIndexedAccess.ts, 16, 1)) |
| 56 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 17, 36)) |
| 57 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 58 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 59 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 60 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 17, 36)) |
| 61 | + |
| 62 | +type TypeHardcodedAsParameterWithoutReturnType<T extends 'Boat', F extends keyof DataFetchFns[T]> = DataFetchFns[T][F]; |
| 63 | +>TypeHardcodedAsParameterWithoutReturnType : Symbol(TypeHardcodedAsParameterWithoutReturnType, Decl(constraintWithIndexedAccess.ts, 17, 112)) |
| 64 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 18, 47)) |
| 65 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 18, 64)) |
| 66 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 67 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 18, 47)) |
| 68 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 69 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 18, 47)) |
| 70 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 18, 64)) |
| 71 | + |
| 72 | +export type allAreFunctionsAsExpected = TypeHardcodedAsParameterWithoutReturnType<'Boat', keyof DataFetchFns['Boat']>; |
| 73 | +>allAreFunctionsAsExpected : Symbol(allAreFunctionsAsExpected, Decl(constraintWithIndexedAccess.ts, 18, 119)) |
| 74 | +>TypeHardcodedAsParameterWithoutReturnType : Symbol(TypeHardcodedAsParameterWithoutReturnType, Decl(constraintWithIndexedAccess.ts, 17, 112)) |
| 75 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 76 | + |
| 77 | +export type returnTypeOfFunctions = ReturnType<allAreFunctionsAsExpected>; //string | number | boolean as expected |
| 78 | +>returnTypeOfFunctions : Symbol(returnTypeOfFunctions, Decl(constraintWithIndexedAccess.ts, 19, 118)) |
| 79 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 80 | +>allAreFunctionsAsExpected : Symbol(allAreFunctionsAsExpected, Decl(constraintWithIndexedAccess.ts, 18, 119)) |
| 81 | + |
| 82 | +export type SucceedingCombo = ReturnType<TypeHardcodedAsParameterWithoutReturnType<'Boat', keyof DataFetchFns['Boat']>>; |
| 83 | +>SucceedingCombo : Symbol(SucceedingCombo, Decl(constraintWithIndexedAccess.ts, 20, 74)) |
| 84 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 85 | +>TypeHardcodedAsParameterWithoutReturnType : Symbol(TypeHardcodedAsParameterWithoutReturnType, Decl(constraintWithIndexedAccess.ts, 17, 112)) |
| 86 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 87 | + |
| 88 | +export type FailingCombo<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<TypeHardcodedAsParameterWithoutReturnType<T,F>>; |
| 89 | +>FailingCombo : Symbol(FailingCombo, Decl(constraintWithIndexedAccess.ts, 21, 120)) |
| 90 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 22, 25)) |
| 91 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 22, 42)) |
| 92 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 93 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 22, 25)) |
| 94 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 95 | +>TypeHardcodedAsParameterWithoutReturnType : Symbol(TypeHardcodedAsParameterWithoutReturnType, Decl(constraintWithIndexedAccess.ts, 17, 112)) |
| 96 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 22, 25)) |
| 97 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 22, 42)) |
| 98 | + |
| 99 | +export type TypeHardcodedAsParameter<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][F]>; |
| 100 | +>TypeHardcodedAsParameter : Symbol(TypeHardcodedAsParameter, Decl(constraintWithIndexedAccess.ts, 22, 137)) |
| 101 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 23, 37)) |
| 102 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 23, 54)) |
| 103 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 104 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 23, 37)) |
| 105 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 106 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 107 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 23, 37)) |
| 108 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 23, 54)) |
| 109 | + |
| 110 | +type VehicleSelector<T extends keyof DataFetchFns> = DataFetchFns[T]; |
| 111 | +>VehicleSelector : Symbol(VehicleSelector, Decl(constraintWithIndexedAccess.ts, 23, 121)) |
| 112 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 24, 21)) |
| 113 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 114 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 115 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 24, 21)) |
| 116 | + |
| 117 | +export type TypeHardcodedAsParameter2<T extends 'Boat', F extends keyof DataFetchFns[T]> = ReturnType<VehicleSelector<T>[F]>; |
| 118 | +>TypeHardcodedAsParameter2 : Symbol(TypeHardcodedAsParameter2, Decl(constraintWithIndexedAccess.ts, 24, 69)) |
| 119 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 25, 38)) |
| 120 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 25, 55)) |
| 121 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 122 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 25, 38)) |
| 123 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 124 | +>VehicleSelector : Symbol(VehicleSelector, Decl(constraintWithIndexedAccess.ts, 23, 121)) |
| 125 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 25, 38)) |
| 126 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 25, 55)) |
| 127 | + |
| 128 | +export type TypeGeneric<T extends keyof DataFetchFns, F extends keyof DataFetchFns[T]> = ReturnType<DataFetchFns[T][F]>; |
| 129 | +>TypeGeneric : Symbol(TypeGeneric, Decl(constraintWithIndexedAccess.ts, 25, 125)) |
| 130 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 26, 24)) |
| 131 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 132 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 26, 53)) |
| 133 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 134 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 26, 24)) |
| 135 | +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) |
| 136 | +>DataFetchFns : Symbol(DataFetchFns, Decl(constraintWithIndexedAccess.ts, 0, 0)) |
| 137 | +>T : Symbol(T, Decl(constraintWithIndexedAccess.ts, 26, 24)) |
| 138 | +>F : Symbol(F, Decl(constraintWithIndexedAccess.ts, 26, 53)) |
| 139 | + |
0 commit comments