forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show issues: overload selection (microsoft#17471), composition
- Loading branch information
1 parent
636b4ac
commit a76ba38
Showing
8 changed files
with
148 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//// [overloadSelection.ts] | ||
interface Match { | ||
(o: object): 0; | ||
(o: any): 1; | ||
} | ||
type Wrap = <T = RegExp>(v: T) => Match(T); | ||
type A = Wrap(RegExp); | ||
// falls thru to 1, `object` checked not with generic val `RegExp` but with its constraint (generic `any`) | ||
|
||
|
||
//// [overloadSelection.js] | ||
// falls thru to 1, `object` checked not with generic val `RegExp` but with its constraint (generic `any`) |
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,26 @@ | ||
=== tests/cases/compiler/overloadSelection.ts === | ||
interface Match { | ||
>Match : Symbol(Match, Decl(overloadSelection.ts, 0, 0)) | ||
|
||
(o: object): 0; | ||
>o : Symbol(o, Decl(overloadSelection.ts, 1, 3)) | ||
|
||
(o: any): 1; | ||
>o : Symbol(o, Decl(overloadSelection.ts, 2, 3)) | ||
} | ||
type Wrap = <T = RegExp>(v: T) => Match(T); | ||
>Wrap : Symbol(Wrap, Decl(overloadSelection.ts, 3, 1)) | ||
>T : Symbol(T, Decl(overloadSelection.ts, 4, 13)) | ||
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) | ||
>v : Symbol(v, Decl(overloadSelection.ts, 4, 25)) | ||
>T : Symbol(T, Decl(overloadSelection.ts, 4, 13)) | ||
>Match : Symbol(Match, Decl(overloadSelection.ts, 0, 0)) | ||
>T : Symbol(T, Decl(overloadSelection.ts, 4, 13)) | ||
|
||
type A = Wrap(RegExp); | ||
>A : Symbol(A, Decl(overloadSelection.ts, 4, 43)) | ||
>Wrap : Symbol(Wrap, Decl(overloadSelection.ts, 3, 1)) | ||
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) | ||
|
||
// falls thru to 1, `object` checked not with generic val `RegExp` but with its constraint (generic `any`) | ||
|
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,26 @@ | ||
=== tests/cases/compiler/overloadSelection.ts === | ||
interface Match { | ||
>Match : Match | ||
|
||
(o: object): 0; | ||
>o : object | ||
|
||
(o: any): 1; | ||
>o : any | ||
} | ||
type Wrap = <T = RegExp>(v: T) => Match(T); | ||
>Wrap : Wrap | ||
>T : T | ||
>RegExp : RegExp | ||
>v : T | ||
>T : T | ||
>Match : Match | ||
>T : T | ||
|
||
type A = Wrap(RegExp); | ||
>A : 1 | ||
>Wrap : Wrap | ||
>RegExp : RegExp | ||
|
||
// falls thru to 1, `object` checked not with generic val `RegExp` but with its constraint (generic `any`) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @allowSyntheticDefaultImports: true | ||
|
||
interface Match { | ||
(o: object): 0; | ||
(o: any): 1; | ||
} | ||
type Wrap = <T = RegExp>(v: T) => Match(T); | ||
type A = Wrap(RegExp); | ||
// falls thru to 1, `object` checked not with generic val `RegExp` but with its constraint (generic `any`) |
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