|
| 1 | +//// [tests/cases/compiler/typeInferenceIndexingUsingOtherTypeParameter1.ts] //// |
| 2 | + |
| 3 | +=== typeInferenceIndexingUsingOtherTypeParameter1.ts === |
| 4 | +type Primitive = null | undefined | string | number | boolean | symbol | bigint; |
| 5 | +>Primitive : Symbol(Primitive, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 0)) |
| 6 | + |
| 7 | +type FieldValues = Record<string, any>; |
| 8 | +>FieldValues : Symbol(FieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 80)) |
| 9 | +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) |
| 10 | + |
| 11 | +type PathImpl< |
| 12 | +>PathImpl : Symbol(PathImpl, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 2, 39)) |
| 13 | + |
| 14 | + K extends string | number, |
| 15 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 4, 14)) |
| 16 | + |
| 17 | + V, |
| 18 | +>V : Symbol(V, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 5, 28)) |
| 19 | + |
| 20 | + TraversedTypes, |
| 21 | +>TraversedTypes : Symbol(TraversedTypes, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 6, 4)) |
| 22 | + |
| 23 | +> = V extends Primitive |
| 24 | +>V : Symbol(V, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 5, 28)) |
| 25 | +>Primitive : Symbol(Primitive, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 0)) |
| 26 | + |
| 27 | + ? `${K}` |
| 28 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 4, 14)) |
| 29 | + |
| 30 | + : `${K}` | `${K}.${PathInternal<V, TraversedTypes | V>}`; |
| 31 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 4, 14)) |
| 32 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 4, 14)) |
| 33 | +>PathInternal : Symbol(PathInternal, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 10, 59)) |
| 34 | +>V : Symbol(V, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 5, 28)) |
| 35 | +>TraversedTypes : Symbol(TraversedTypes, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 6, 4)) |
| 36 | +>V : Symbol(V, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 5, 28)) |
| 37 | + |
| 38 | +type PathInternal<T, TraversedTypes = T> = { |
| 39 | +>PathInternal : Symbol(PathInternal, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 10, 59)) |
| 40 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 12, 18)) |
| 41 | +>TraversedTypes : Symbol(TraversedTypes, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 12, 20)) |
| 42 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 12, 18)) |
| 43 | + |
| 44 | + [K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes>; |
| 45 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 13, 3)) |
| 46 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 12, 18)) |
| 47 | +>PathImpl : Symbol(PathImpl, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 2, 39)) |
| 48 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 13, 3)) |
| 49 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 12, 18)) |
| 50 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 13, 3)) |
| 51 | +>TraversedTypes : Symbol(TraversedTypes, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 12, 20)) |
| 52 | + |
| 53 | +}[keyof T]; |
| 54 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 12, 18)) |
| 55 | + |
| 56 | +type Path<T> = T extends any ? PathInternal<T> : never; |
| 57 | +>Path : Symbol(Path, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 14, 11)) |
| 58 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 10)) |
| 59 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 10)) |
| 60 | +>PathInternal : Symbol(PathInternal, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 10, 59)) |
| 61 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 10)) |
| 62 | + |
| 63 | +type FieldPath<TFieldValues extends FieldValues> = Path<TFieldValues>; |
| 64 | +>FieldPath : Symbol(FieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 55)) |
| 65 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 18, 15)) |
| 66 | +>FieldValues : Symbol(FieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 80)) |
| 67 | +>Path : Symbol(Path, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 14, 11)) |
| 68 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 18, 15)) |
| 69 | + |
| 70 | +type PathValue<T, P extends Path<T>> = T extends any |
| 71 | +>PathValue : Symbol(PathValue, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 18, 70)) |
| 72 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 73 | +>P : Symbol(P, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 17)) |
| 74 | +>Path : Symbol(Path, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 14, 11)) |
| 75 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 76 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 77 | + |
| 78 | + ? P extends `${infer K}.${infer R}` |
| 79 | +>P : Symbol(P, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 17)) |
| 80 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 21, 22)) |
| 81 | +>R : Symbol(R, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 21, 33)) |
| 82 | + |
| 83 | + ? K extends keyof T |
| 84 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 21, 22)) |
| 85 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 86 | + |
| 87 | + ? R extends Path<T[K]> |
| 88 | +>R : Symbol(R, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 21, 33)) |
| 89 | +>Path : Symbol(Path, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 14, 11)) |
| 90 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 91 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 21, 22)) |
| 92 | + |
| 93 | + ? PathValue<T[K], R> |
| 94 | +>PathValue : Symbol(PathValue, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 18, 70)) |
| 95 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 96 | +>K : Symbol(K, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 21, 22)) |
| 97 | +>R : Symbol(R, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 21, 33)) |
| 98 | + |
| 99 | + : never |
| 100 | + : never |
| 101 | + : P extends keyof T |
| 102 | +>P : Symbol(P, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 17)) |
| 103 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 104 | + |
| 105 | + ? T[P] |
| 106 | +>T : Symbol(T, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 15)) |
| 107 | +>P : Symbol(P, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 20, 17)) |
| 108 | + |
| 109 | + : never |
| 110 | + : never; |
| 111 | + |
| 112 | +type FieldPathValue< |
| 113 | +>FieldPathValue : Symbol(FieldPathValue, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 30, 10)) |
| 114 | + |
| 115 | + TFieldValues extends FieldValues, |
| 116 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 32, 20)) |
| 117 | +>FieldValues : Symbol(FieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 80)) |
| 118 | + |
| 119 | + TFieldPath extends FieldPath<TFieldValues>, |
| 120 | +>TFieldPath : Symbol(TFieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 33, 35)) |
| 121 | +>FieldPath : Symbol(FieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 55)) |
| 122 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 32, 20)) |
| 123 | + |
| 124 | +> = PathValue<TFieldValues, TFieldPath>; |
| 125 | +>PathValue : Symbol(PathValue, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 18, 70)) |
| 126 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 32, 20)) |
| 127 | +>TFieldPath : Symbol(TFieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 33, 35)) |
| 128 | + |
| 129 | +type UseControllerProps< |
| 130 | +>UseControllerProps : Symbol(UseControllerProps, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 35, 40)) |
| 131 | + |
| 132 | + TFieldValues extends FieldValues = FieldValues, |
| 133 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 37, 24)) |
| 134 | +>FieldValues : Symbol(FieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 80)) |
| 135 | +>FieldValues : Symbol(FieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 80)) |
| 136 | + |
| 137 | + TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, |
| 138 | +>TName : Symbol(TName, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 38, 49)) |
| 139 | +>FieldPath : Symbol(FieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 55)) |
| 140 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 37, 24)) |
| 141 | +>FieldPath : Symbol(FieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 55)) |
| 142 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 37, 24)) |
| 143 | + |
| 144 | +> = { |
| 145 | + name: TName; |
| 146 | +>name : Symbol(name, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 40, 5)) |
| 147 | +>TName : Symbol(TName, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 38, 49)) |
| 148 | + |
| 149 | + defaultValue?: FieldPathValue<TFieldValues, TName>; |
| 150 | +>defaultValue : Symbol(defaultValue, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 41, 14)) |
| 151 | +>FieldPathValue : Symbol(FieldPathValue, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 30, 10)) |
| 152 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 37, 24)) |
| 153 | +>TName : Symbol(TName, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 38, 49)) |
| 154 | + |
| 155 | +}; |
| 156 | + |
| 157 | +declare function useController< |
| 158 | +>useController : Symbol(useController, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 43, 2)) |
| 159 | + |
| 160 | + TFieldValues extends FieldValues = FieldValues, |
| 161 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 45, 31)) |
| 162 | +>FieldValues : Symbol(FieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 80)) |
| 163 | +>FieldValues : Symbol(FieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 0, 80)) |
| 164 | + |
| 165 | + TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, |
| 166 | +>TName : Symbol(TName, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 46, 49)) |
| 167 | +>FieldPath : Symbol(FieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 55)) |
| 168 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 45, 31)) |
| 169 | +>FieldPath : Symbol(FieldPath, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 16, 55)) |
| 170 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 45, 31)) |
| 171 | + |
| 172 | +>( |
| 173 | + props: UseControllerProps<TFieldValues, TName>, |
| 174 | +>props : Symbol(props, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 48, 2)) |
| 175 | +>UseControllerProps : Symbol(UseControllerProps, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 35, 40)) |
| 176 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 45, 31)) |
| 177 | +>TName : Symbol(TName, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 46, 49)) |
| 178 | + |
| 179 | +): { name: TName; values: TFieldValues }; |
| 180 | +>name : Symbol(name, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 50, 4)) |
| 181 | +>TName : Symbol(TName, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 46, 49)) |
| 182 | +>values : Symbol(values, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 50, 17)) |
| 183 | +>TFieldValues : Symbol(TFieldValues, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 45, 31)) |
| 184 | + |
| 185 | +export const { name, values } = useController({ |
| 186 | +>name : Symbol(name, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 52, 14)) |
| 187 | +>values : Symbol(values, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 52, 20)) |
| 188 | +>useController : Symbol(useController, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 43, 2)) |
| 189 | + |
| 190 | + name: "test", |
| 191 | +>name : Symbol(name, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 52, 47)) |
| 192 | + |
| 193 | + defaultValue: "", |
| 194 | +>defaultValue : Symbol(defaultValue, Decl(typeInferenceIndexingUsingOtherTypeParameter1.ts, 53, 15)) |
| 195 | + |
| 196 | +}); |
| 197 | + |
0 commit comments