-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow infer types in type argument positions
- Loading branch information
Showing
14 changed files
with
298 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/inferTypeArgumentKeyword.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
tests/cases/conformance/types/typeParameters/typeArgumentLists/inferTypeArgumentKeyword.ts(7,51): error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { y: number; }; }'. | ||
Types of property 'z' are incompatible. | ||
Type 'number' is not assignable to type '{ y: number; }'. | ||
tests/cases/conformance/types/typeParameters/typeArgumentLists/inferTypeArgumentKeyword.ts(10,30): error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type 'number'. | ||
|
||
|
||
==== tests/cases/conformance/types/typeParameters/typeArgumentLists/inferTypeArgumentKeyword.ts (2 errors) ==== | ||
declare function foo<A, B, C>(x: A, y: B, z: { z: C }): A & B & C; | ||
|
||
// good | ||
foo<infer A, {x: string}, A>({y: 12}, {x: "yes"}, {z: {y: 12}}); | ||
|
||
// error on 3rd arg | ||
foo<infer A, {x: string}, A>({y: 12}, {x: "yes"}, {z: 12}); | ||
~~~~~~~ | ||
!!! error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { y: number; }; }'. | ||
!!! error TS2345: Types of property 'z' are incompatible. | ||
!!! error TS2345: Type 'number' is not assignable to type '{ y: number; }'. | ||
|
||
// error on first arg | ||
foo<A, {x: string}, infer A>({y: 12}, {x: "yes"}, {z: 12}); | ||
~~~~~~~ | ||
!!! error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type 'number'. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [inferTypeArgumentKeyword.ts] | ||
declare function foo<A, B, C>(x: A, y: B, z: { z: C }): A & B & C; | ||
|
||
// good | ||
foo<infer A, {x: string}, A>({y: 12}, {x: "yes"}, {z: {y: 12}}); | ||
|
||
// error on 3rd arg | ||
foo<infer A, {x: string}, A>({y: 12}, {x: "yes"}, {z: 12}); | ||
|
||
// error on first arg | ||
foo<A, {x: string}, infer A>({y: 12}, {x: "yes"}, {z: 12}); | ||
|
||
|
||
//// [inferTypeArgumentKeyword.js] | ||
// good | ||
foo({ y: 12 }, { x: "yes" }, { z: { y: 12 } }); | ||
// error on 3rd arg | ||
foo({ y: 12 }, { x: "yes" }, { z: 12 }); | ||
// error on first arg | ||
foo({ y: 12 }, { x: "yes" }, { z: 12 }); |
Oops, something went wrong.