Skip to content

Commit fae5ae6

Browse files
committed
Add an extra test case for array literals used as values of object reverse mapped types
1 parent 57b54c9 commit fae5ae6

File tree

5 files changed

+211
-0
lines changed

5 files changed

+211
-0
lines changed

tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.errors.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,24 @@ tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInf
145145
consume: (x) => x.v.toLowerCase(),
146146
},
147147
});
148+
149+
declare function f4<T>(
150+
arg: {
151+
[K in keyof T]: [
152+
(n: string) => T[K],
153+
(x: T[K]) => void
154+
];
155+
}
156+
): T;
157+
158+
const res8 = f4({
159+
a: [
160+
(n) => n,
161+
(x) => x.toLowerCase(),
162+
],
163+
b: [
164+
(n) => ({ v: n }),
165+
(x) => x.v.toLowerCase(),
166+
],
167+
});
148168

tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,26 @@ const res7 = f3({
125125
consume: (x) => x.v.toLowerCase(),
126126
},
127127
});
128+
129+
declare function f4<T>(
130+
arg: {
131+
[K in keyof T]: [
132+
(n: string) => T[K],
133+
(x: T[K]) => void
134+
];
135+
}
136+
): T;
137+
138+
const res8 = f4({
139+
a: [
140+
(n) => n,
141+
(x) => x.toLowerCase(),
142+
],
143+
b: [
144+
(n) => ({ v: n }),
145+
(x) => x.v.toLowerCase(),
146+
],
147+
});
128148

129149

130150
//// [intraExpressionInferencesReverseMappedTypes.js]
@@ -218,6 +238,16 @@ var res7 = f3({
218238
consume: function (x) { return x.v.toLowerCase(); },
219239
},
220240
});
241+
var res8 = f4({
242+
a: [
243+
function (n) { return n; },
244+
function (x) { return x.toLowerCase(); },
245+
],
246+
b: [
247+
function (n) { return ({ v: n }); },
248+
function (x) { return x.v.toLowerCase(); },
249+
],
250+
});
221251

222252

223253
//// [intraExpressionInferencesReverseMappedTypes.d.ts]
@@ -275,3 +305,15 @@ declare const res7: {
275305
v: string;
276306
};
277307
};
308+
declare function f4<T>(arg: {
309+
[K in keyof T]: [
310+
(n: string) => T[K],
311+
(x: T[K]) => void
312+
];
313+
}): T;
314+
declare const res8: {
315+
a: string;
316+
b: {
317+
v: string;
318+
};
319+
};

tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.symbols

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,66 @@ const res7 = f3({
354354
},
355355
});
356356

357+
declare function f4<T>(
358+
>f4 : Symbol(f4, Decl(intraExpressionInferencesReverseMappedTypes.ts, 125, 3))
359+
>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20))
360+
361+
arg: {
362+
>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 23))
363+
364+
[K in keyof T]: [
365+
>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 129, 5))
366+
>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20))
367+
368+
(n: string) => T[K],
369+
>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 130, 7))
370+
>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20))
371+
>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 129, 5))
372+
373+
(x: T[K]) => void
374+
>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 131, 7))
375+
>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20))
376+
>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 129, 5))
377+
378+
];
379+
}
380+
): T;
381+
>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20))
382+
383+
const res8 = f4({
384+
>res8 : Symbol(res8, Decl(intraExpressionInferencesReverseMappedTypes.ts, 136, 5))
385+
>f4 : Symbol(f4, Decl(intraExpressionInferencesReverseMappedTypes.ts, 125, 3))
386+
387+
a: [
388+
>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 136, 17))
389+
390+
(n) => n,
391+
>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 138, 5))
392+
>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 138, 5))
393+
394+
(x) => x.toLowerCase(),
395+
>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 139, 5))
396+
>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
397+
>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 139, 5))
398+
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
399+
400+
],
401+
b: [
402+
>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 140, 4))
403+
404+
(n) => ({ v: n }),
405+
>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 5))
406+
>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 13))
407+
>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 5))
408+
409+
(x) => x.v.toLowerCase(),
410+
>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 143, 5))
411+
>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
412+
>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 13))
413+
>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 143, 5))
414+
>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 13))
415+
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
416+
417+
],
418+
});
419+

tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.types

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,69 @@ const res7 = f3({
441441
},
442442
});
443443

444+
declare function f4<T>(
445+
>f4 : <T>(arg: { [K in keyof T]: [(n: string) => T[K], (x: T[K]) => void]; }) => T
446+
447+
arg: {
448+
>arg : { [K in keyof T]: [(n: string) => T[K], (x: T[K]) => void]; }
449+
450+
[K in keyof T]: [
451+
(n: string) => T[K],
452+
>n : string
453+
454+
(x: T[K]) => void
455+
>x : T[K]
456+
457+
];
458+
}
459+
): T;
460+
461+
const res8 = f4({
462+
>res8 : { a: string; b: { v: string; }; }
463+
>f4({ a: [ (n) => n, (x) => x.toLowerCase(), ], b: [ (n) => ({ v: n }), (x) => x.v.toLowerCase(), ],}) : { a: string; b: { v: string; }; }
464+
>f4 : <T>(arg: { [K in keyof T]: [(n: string) => T[K], (x: T[K]) => void]; }) => T
465+
>{ a: [ (n) => n, (x) => x.toLowerCase(), ], b: [ (n) => ({ v: n }), (x) => x.v.toLowerCase(), ],} : { a: [(n: string) => string, (x: string) => string]; b: [(n: string) => { v: string; }, (x: { v: string; }) => string]; }
466+
467+
a: [
468+
>a : [(n: string) => string, (x: string) => string]
469+
>[ (n) => n, (x) => x.toLowerCase(), ] : [(n: string) => string, (x: string) => string]
470+
471+
(n) => n,
472+
>(n) => n : (n: string) => string
473+
>n : string
474+
>n : string
475+
476+
(x) => x.toLowerCase(),
477+
>(x) => x.toLowerCase() : (x: string) => string
478+
>x : string
479+
>x.toLowerCase() : string
480+
>x.toLowerCase : () => string
481+
>x : string
482+
>toLowerCase : () => string
483+
484+
],
485+
b: [
486+
>b : [(n: string) => { v: string; }, (x: { v: string; }) => string]
487+
>[ (n) => ({ v: n }), (x) => x.v.toLowerCase(), ] : [(n: string) => { v: string; }, (x: { v: string; }) => string]
488+
489+
(n) => ({ v: n }),
490+
>(n) => ({ v: n }) : (n: string) => { v: string; }
491+
>n : string
492+
>({ v: n }) : { v: string; }
493+
>{ v: n } : { v: string; }
494+
>v : string
495+
>n : string
496+
497+
(x) => x.v.toLowerCase(),
498+
>(x) => x.v.toLowerCase() : (x: { v: string; }) => string
499+
>x : { v: string; }
500+
>x.v.toLowerCase() : string
501+
>x.v.toLowerCase : () => string
502+
>x.v : string
503+
>x : { v: string; }
504+
>v : string
505+
>toLowerCase : () => string
506+
507+
],
508+
});
509+

tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesReverseMappedTypes.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,23 @@ const res7 = f3({
127127
consume: (x) => x.v.toLowerCase(),
128128
},
129129
});
130+
131+
declare function f4<T>(
132+
arg: {
133+
[K in keyof T]: [
134+
(n: string) => T[K],
135+
(x: T[K]) => void
136+
];
137+
}
138+
): T;
139+
140+
const res8 = f4({
141+
a: [
142+
(n) => n,
143+
(x) => x.toLowerCase(),
144+
],
145+
b: [
146+
(n) => ({ v: n }),
147+
(x) => x.v.toLowerCase(),
148+
],
149+
});

0 commit comments

Comments
 (0)