@@ -104,3 +104,70 @@ const get = <T extends string>(t: T, foo: Foo<T>): T => foo[`get${t}`]; // Type
104
104
>foo : Symbol(foo, Decl(mappedTypeConstraints2.ts, 24, 36))
105
105
>t : Symbol(t, Decl(mappedTypeConstraints2.ts, 24, 31))
106
106
107
+ // Repro from #48626
108
+
109
+ interface Bounds {
110
+ >Bounds : Symbol(Bounds, Decl(mappedTypeConstraints2.ts, 24, 71))
111
+
112
+ min: number;
113
+ >min : Symbol(Bounds.min, Decl(mappedTypeConstraints2.ts, 28, 18))
114
+
115
+ max: number;
116
+ >max : Symbol(Bounds.max, Decl(mappedTypeConstraints2.ts, 29, 16))
117
+ }
118
+
119
+ type NumericBoundsOf<T> = {
120
+ >NumericBoundsOf : Symbol(NumericBoundsOf, Decl(mappedTypeConstraints2.ts, 31, 1))
121
+ >T : Symbol(T, Decl(mappedTypeConstraints2.ts, 33, 21))
122
+
123
+ [K in keyof T as T[K] extends number | undefined ? K : never]: Bounds;
124
+ >K : Symbol(K, Decl(mappedTypeConstraints2.ts, 34, 5))
125
+ >T : Symbol(T, Decl(mappedTypeConstraints2.ts, 33, 21))
126
+ >T : Symbol(T, Decl(mappedTypeConstraints2.ts, 33, 21))
127
+ >K : Symbol(K, Decl(mappedTypeConstraints2.ts, 34, 5))
128
+ >K : Symbol(K, Decl(mappedTypeConstraints2.ts, 34, 5))
129
+ >Bounds : Symbol(Bounds, Decl(mappedTypeConstraints2.ts, 24, 71))
130
+ }
131
+
132
+ function validate<T extends object>(obj: T, bounds: NumericBoundsOf<T>) {
133
+ >validate : Symbol(validate, Decl(mappedTypeConstraints2.ts, 35, 1))
134
+ >T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18))
135
+ >obj : Symbol(obj, Decl(mappedTypeConstraints2.ts, 37, 36))
136
+ >T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18))
137
+ >bounds : Symbol(bounds, Decl(mappedTypeConstraints2.ts, 37, 43))
138
+ >NumericBoundsOf : Symbol(NumericBoundsOf, Decl(mappedTypeConstraints2.ts, 31, 1))
139
+ >T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18))
140
+
141
+ for (const [key, val] of Object.entries(obj)) {
142
+ >key : Symbol(key, Decl(mappedTypeConstraints2.ts, 38, 16))
143
+ >val : Symbol(val, Decl(mappedTypeConstraints2.ts, 38, 20))
144
+ >Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --))
145
+ >Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
146
+ >entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --))
147
+ >obj : Symbol(obj, Decl(mappedTypeConstraints2.ts, 37, 36))
148
+
149
+ const boundsForKey = bounds[key as keyof NumericBoundsOf<T>];
150
+ >boundsForKey : Symbol(boundsForKey, Decl(mappedTypeConstraints2.ts, 39, 13))
151
+ >bounds : Symbol(bounds, Decl(mappedTypeConstraints2.ts, 37, 43))
152
+ >key : Symbol(key, Decl(mappedTypeConstraints2.ts, 38, 16))
153
+ >NumericBoundsOf : Symbol(NumericBoundsOf, Decl(mappedTypeConstraints2.ts, 31, 1))
154
+ >T : Symbol(T, Decl(mappedTypeConstraints2.ts, 37, 18))
155
+
156
+ if (boundsForKey) {
157
+ >boundsForKey : Symbol(boundsForKey, Decl(mappedTypeConstraints2.ts, 39, 13))
158
+
159
+ const { min, max } = boundsForKey;
160
+ >min : Symbol(min, Decl(mappedTypeConstraints2.ts, 41, 19))
161
+ >max : Symbol(max, Decl(mappedTypeConstraints2.ts, 41, 24))
162
+ >boundsForKey : Symbol(boundsForKey, Decl(mappedTypeConstraints2.ts, 39, 13))
163
+
164
+ if (min > val || max < val) return false;
165
+ >min : Symbol(min, Decl(mappedTypeConstraints2.ts, 41, 19))
166
+ >val : Symbol(val, Decl(mappedTypeConstraints2.ts, 38, 20))
167
+ >max : Symbol(max, Decl(mappedTypeConstraints2.ts, 41, 24))
168
+ >val : Symbol(val, Decl(mappedTypeConstraints2.ts, 38, 20))
169
+ }
170
+ }
171
+ return true;
172
+ }
173
+
0 commit comments