1- noInfer.ts(29 ,13): error TS2345: Argument of type '"bar"' is not assignable to parameter of type '"foo"'.
2- noInfer.ts(30 ,14): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
3- noInfer.ts(31 ,14): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
4- noInfer.ts(32 ,15): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
5- noInfer.ts(33 ,15): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
6- noInfer.ts(41 ,30): error TS2741: Property 'woof' is missing in type 'Animal' but required in type 'Dog'.
7- noInfer.ts(47 ,16): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type '{ x: number; y: number; }'.
1+ noInfer.ts(35 ,13): error TS2345: Argument of type '"bar"' is not assignable to parameter of type '"foo"'.
2+ noInfer.ts(36 ,14): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
3+ noInfer.ts(37 ,14): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
4+ noInfer.ts(38 ,15): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
5+ noInfer.ts(39 ,15): error TS2322: Type '"bar"' is not assignable to type '"foo"'.
6+ noInfer.ts(47 ,30): error TS2741: Property 'woof' is missing in type 'Animal' but required in type 'Dog'.
7+ noInfer.ts(53 ,16): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type '{ x: number; y: number; }'.
88 Property 'y' is missing in type '{ x: number; }' but required in type '{ x: number; y: number; }'.
9- noInfer.ts(52 ,22): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'.
10- noInfer.ts(53 ,14): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'.
11- noInfer.ts(60 ,14): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ foo: number; }'.
9+ noInfer.ts(58 ,22): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'.
10+ noInfer.ts(59 ,14): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'.
11+ noInfer.ts(66 ,14): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ foo: number; }'.
1212 Property 'foo' is missing in type '{}' but required in type '{ foo: number; }'.
1313
1414
@@ -34,6 +34,12 @@ noInfer.ts(60,14): error TS2345: Argument of type '{}' is not assignable to para
3434 type T21<T> = NoInfer<NoInfer<T> & string>;
3535 type T22<T> = NoInfer<NoInfer<T> & string[]>;
3636
37+ // NoInfer<T> is erased in index types and mapped types
38+
39+ type T30 = keyof NoInfer<{ a: string, b: string }>;
40+ type T31<T> = keyof NoInfer<T>;
41+ type T32 = { [K in keyof NoInfer<{ a: string, b: string }>]: K };
42+
3743 declare function foo1<T extends string>(a: T, b: NoInfer<T>): void
3844 declare function foo2<T extends string>(a: T, b: NoInfer<T>[]): void
3945 declare function foo3<T extends string>(a: T, b: NoInfer<T[]>): void
@@ -53,11 +59,11 @@ noInfer.ts(60,14): error TS2345: Argument of type '{}' is not assignable to para
5359 foo4('foo', { x: 'bar' }) // error
5460 ~
5561!!! error TS2322: Type '"bar"' is not assignable to type '"foo"'.
56- !!! related TS6500 noInfer.ts:25 :52: The expected type comes from property 'x' which is declared here on type '{ x: "foo"; }'
62+ !!! related TS6500 noInfer.ts:31 :52: The expected type comes from property 'x' which is declared here on type '{ x: "foo"; }'
5763 foo5('foo', { x: 'bar' }) // error
5864 ~
5965!!! error TS2322: Type '"bar"' is not assignable to type '"foo"'.
60- !!! related TS6500 noInfer.ts:26 :60: The expected type comes from property 'x' which is declared here on type 'NoInfer<{ x: "foo"; }>'
66+ !!! related TS6500 noInfer.ts:32 :60: The expected type comes from property 'x' which is declared here on type 'NoInfer<{ x: "foo"; }>'
6167
6268 declare class Animal { move(): void }
6369 declare class Dog extends Animal { woof(): void }
@@ -68,8 +74,8 @@ noInfer.ts(60,14): error TS2345: Argument of type '{}' is not assignable to para
6874 doSomething(new Dog(), () => new Animal()); // error
6975 ~~~~~~~~~~~~
7076!!! error TS2741: Property 'woof' is missing in type 'Animal' but required in type 'Dog'.
71- !!! related TS2728 noInfer.ts:36 :36: 'woof' is declared here.
72- !!! related TS6502 noInfer.ts:37 :55: The expected type comes from the return type of this signature.
77+ !!! related TS2728 noInfer.ts:42 :36: 'woof' is declared here.
78+ !!! related TS6502 noInfer.ts:43 :55: The expected type comes from the return type of this signature.
7379
7480 declare function assertEqual<T>(actual: T, expected: NoInfer<T>): boolean;
7581
@@ -79,7 +85,7 @@ noInfer.ts(60,14): error TS2345: Argument of type '{}' is not assignable to para
7985 ~~~~~~~~
8086!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type '{ x: number; y: number; }'.
8187!!! error TS2345: Property 'y' is missing in type '{ x: number; }' but required in type '{ x: number; y: number; }'.
82- !!! related TS2728 noInfer.ts:46 :19: 'y' is declared here.
88+ !!! related TS2728 noInfer.ts:52 :19: 'y' is declared here.
8389
8490 declare function invoke<T, R>(func: (value: T) => R, value: NoInfer<T>): R;
8591 declare function test(value: { x: number; }): number;
@@ -100,7 +106,7 @@ noInfer.ts(60,14): error TS2345: Argument of type '{}' is not assignable to para
100106 ~~
101107!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ foo: number; }'.
102108!!! error TS2345: Property 'foo' is missing in type '{}' but required in type '{ foo: number; }'.
103- !!! related TS2728 noInfer.ts:57 :33: 'foo' is declared here.
109+ !!! related TS2728 noInfer.ts:63 :33: 'foo' is declared here.
104110
105111 declare function mutate<T>(callback: (a: NoInfer<T>, b: number) => T): T;
106112 const mutate1 = mutate((a, b) => b);
0 commit comments