Skip to content

Commit b5c6ef4

Browse files
committed
add extra tests
1 parent 5086dfa commit b5c6ef4

5 files changed

Lines changed: 811 additions & 101 deletions

tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.errors.txt

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,63 @@ intraExpressionInferencesReverseMappedTypes.ts(101,21): error TS18046: 'x' is of
217217
},
218218
});
219219

220+
const res11 = f6({
221+
a: () => {
222+
return {
223+
produce: (n) => n,
224+
consume: (x) => x.toLowerCase(),
225+
};
226+
},
227+
b: () => {
228+
return {
229+
produce: (n) => ({ v: n }),
230+
consume: (x) => x.v.toLowerCase(),
231+
};
232+
},
233+
});
234+
220235
declare function f7<T>(arg: {
236+
[K in keyof T]: (arg: boolean) => {
237+
produce: (n: string) => T[K];
238+
consume: (x: T[K]) => void;
239+
};
240+
}): T;
241+
242+
const res12 = f7({
243+
a(arg) {
244+
return {
245+
produce: (n) => n,
246+
consume: (x) => x.toLowerCase(),
247+
};
248+
},
249+
b(arg) {
250+
return {
251+
produce: (n) => ({ v: n }),
252+
consume: (x) => x.v.toLowerCase(),
253+
};
254+
},
255+
});
256+
257+
const res13 = f7({
258+
a: (arg) => {
259+
return {
260+
produce: (n) => n,
261+
consume: (x) => x.toLowerCase(),
262+
};
263+
},
264+
b: (arg) => {
265+
return {
266+
produce: (n) => ({ v: n }),
267+
consume: (x) => x.v.toLowerCase(),
268+
};
269+
},
270+
});
271+
272+
declare function f8<T>(arg: {
221273
[K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void];
222274
}): T;
223275

224-
const res11 = f7({
276+
const res14 = f8({
225277
a() {
226278
return [(n) => n, (x) => x.toLowerCase()];
227279
},
@@ -230,7 +282,7 @@ intraExpressionInferencesReverseMappedTypes.ts(101,21): error TS18046: 'x' is of
230282
},
231283
});
232284

233-
declare function f8<T1, T2>(
285+
declare function f9<T1, T2>(
234286
arg: {
235287
[K in keyof T1]: {
236288
produce: (n: string) => [T1[K], any];
@@ -244,7 +296,7 @@ intraExpressionInferencesReverseMappedTypes.ts(101,21): error TS18046: 'x' is of
244296
},
245297
): [T1, T2];
246298

247-
const res12 = f8({
299+
const res15 = f9({
248300
a: {
249301
produce: (n) => [n, [n]],
250302
consume2: (x) => x[0].toLowerCase(),

tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.js

Lines changed: 126 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,63 @@ const res10 = f6({
199199
},
200200
});
201201

202+
const res11 = f6({
203+
a: () => {
204+
return {
205+
produce: (n) => n,
206+
consume: (x) => x.toLowerCase(),
207+
};
208+
},
209+
b: () => {
210+
return {
211+
produce: (n) => ({ v: n }),
212+
consume: (x) => x.v.toLowerCase(),
213+
};
214+
},
215+
});
216+
202217
declare function f7<T>(arg: {
218+
[K in keyof T]: (arg: boolean) => {
219+
produce: (n: string) => T[K];
220+
consume: (x: T[K]) => void;
221+
};
222+
}): T;
223+
224+
const res12 = f7({
225+
a(arg) {
226+
return {
227+
produce: (n) => n,
228+
consume: (x) => x.toLowerCase(),
229+
};
230+
},
231+
b(arg) {
232+
return {
233+
produce: (n) => ({ v: n }),
234+
consume: (x) => x.v.toLowerCase(),
235+
};
236+
},
237+
});
238+
239+
const res13 = f7({
240+
a: (arg) => {
241+
return {
242+
produce: (n) => n,
243+
consume: (x) => x.toLowerCase(),
244+
};
245+
},
246+
b: (arg) => {
247+
return {
248+
produce: (n) => ({ v: n }),
249+
consume: (x) => x.v.toLowerCase(),
250+
};
251+
},
252+
});
253+
254+
declare function f8<T>(arg: {
203255
[K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void];
204256
}): T;
205257

206-
const res11 = f7({
258+
const res14 = f8({
207259
a() {
208260
return [(n) => n, (x) => x.toLowerCase()];
209261
},
@@ -212,7 +264,7 @@ const res11 = f7({
212264
},
213265
});
214266

215-
declare function f8<T1, T2>(
267+
declare function f9<T1, T2>(
216268
arg: {
217269
[K in keyof T1]: {
218270
produce: (n: string) => [T1[K], any];
@@ -226,7 +278,7 @@ declare function f8<T1, T2>(
226278
},
227279
): [T1, T2];
228280

229-
const res12 = f8({
281+
const res15 = f9({
230282
a: {
231283
produce: (n) => [n, [n]],
232284
consume2: (x) => x[0].toLowerCase(),
@@ -368,15 +420,57 @@ var res10 = f6({
368420
};
369421
},
370422
});
371-
var res11 = f7({
423+
var res11 = f6({
424+
a: function () {
425+
return {
426+
produce: function (n) { return n; },
427+
consume: function (x) { return x.toLowerCase(); },
428+
};
429+
},
430+
b: function () {
431+
return {
432+
produce: function (n) { return ({ v: n }); },
433+
consume: function (x) { return x.v.toLowerCase(); },
434+
};
435+
},
436+
});
437+
var res12 = f7({
438+
a: function (arg) {
439+
return {
440+
produce: function (n) { return n; },
441+
consume: function (x) { return x.toLowerCase(); },
442+
};
443+
},
444+
b: function (arg) {
445+
return {
446+
produce: function (n) { return ({ v: n }); },
447+
consume: function (x) { return x.v.toLowerCase(); },
448+
};
449+
},
450+
});
451+
var res13 = f7({
452+
a: function (arg) {
453+
return {
454+
produce: function (n) { return n; },
455+
consume: function (x) { return x.toLowerCase(); },
456+
};
457+
},
458+
b: function (arg) {
459+
return {
460+
produce: function (n) { return ({ v: n }); },
461+
consume: function (x) { return x.v.toLowerCase(); },
462+
};
463+
},
464+
});
465+
var res14 = f8({
372466
a: function () {
373467
return [function (n) { return n; }, function (x) { return x.toLowerCase(); }];
374468
},
375469
b: function () {
376470
return [function (n) { return ({ v: n }); }, function (x) { return x.v.toLowerCase(); }];
377471
},
378472
});
379-
var res12 = f8({
473+
var res15 = f9({
380474
a: {
381475
produce: function (n) { return [n, [n]]; },
382476
consume2: function (x) { return x[0].toLowerCase(); },
@@ -490,16 +584,40 @@ declare const res10: {
490584
v: string;
491585
};
492586
};
587+
declare const res11: {
588+
a: string;
589+
b: {
590+
v: string;
591+
};
592+
};
493593
declare function f7<T>(arg: {
594+
[K in keyof T]: (arg: boolean) => {
595+
produce: (n: string) => T[K];
596+
consume: (x: T[K]) => void;
597+
};
598+
}): T;
599+
declare const res12: {
600+
a: string;
601+
b: {
602+
v: string;
603+
};
604+
};
605+
declare const res13: {
606+
a: string;
607+
b: {
608+
v: string;
609+
};
610+
};
611+
declare function f8<T>(arg: {
494612
[K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void];
495613
}): T;
496-
declare const res11: {
614+
declare const res14: {
497615
a: string;
498616
b: {
499617
v: string;
500618
};
501619
};
502-
declare function f8<T1, T2>(arg: {
620+
declare function f9<T1, T2>(arg: {
503621
[K in keyof T1]: {
504622
produce: (n: string) => [T1[K], any];
505623
consume: (x: T1[K]) => void;
@@ -510,7 +628,7 @@ declare function f8<T1, T2>(arg: {
510628
consume2: (x: T2) => void;
511629
};
512630
}): [T1, T2];
513-
declare const res12: [{
631+
declare const res15: [{
514632
a: string;
515633
b: {
516634
v: string;

0 commit comments

Comments
 (0)