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.
Filter out non-array types when contextually typing array literal ele…
…ments (microsoft#52589)
- Loading branch information
Showing
10 changed files
with
297 additions
and
13 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
27 changes: 27 additions & 0 deletions
27
...lines/reference/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.symbols
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,27 @@ | ||
=== tests/cases/compiler/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts === | ||
// repro from #52588 | ||
|
||
declare function test( | ||
>test : Symbol(test, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts, 0, 0)) | ||
|
||
arg: Record<string, (arg: string) => void> | Array<(arg: number) => void> | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts, 2, 22)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts, 3, 23)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts, 3, 54)) | ||
|
||
): void; | ||
|
||
test([ | ||
>test : Symbol(test, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts, 0, 0)) | ||
|
||
(arg) => { | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts, 7, 3)) | ||
|
||
arg; // number | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts, 7, 3)) | ||
|
||
}, | ||
]); | ||
|
28 changes: 28 additions & 0 deletions
28
...selines/reference/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.types
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,28 @@ | ||
=== tests/cases/compiler/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts === | ||
// repro from #52588 | ||
|
||
declare function test( | ||
>test : (arg: Record<string, (arg: string) => void> | ((arg: number) => void)[]) => void | ||
|
||
arg: Record<string, (arg: string) => void> | Array<(arg: number) => void> | ||
>arg : Record<string, (arg: string) => void> | ((arg: number) => void)[] | ||
>arg : string | ||
>arg : number | ||
|
||
): void; | ||
|
||
test([ | ||
>test([ (arg) => { arg; // number },]) : void | ||
>test : (arg: Record<string, (arg: string) => void> | ((arg: number) => void)[]) => void | ||
>[ (arg) => { arg; // number },] : ((arg: number) => void)[] | ||
|
||
(arg) => { | ||
>(arg) => { arg; // number } : (arg: number) => void | ||
>arg : number | ||
|
||
arg; // number | ||
>arg : number | ||
|
||
}, | ||
]); | ||
|
27 changes: 27 additions & 0 deletions
27
...aselines/reference/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.symbols
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,27 @@ | ||
=== tests/cases/compiler/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts === | ||
// repro from #52588 | ||
|
||
declare function test( | ||
>test : Symbol(test, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts, 0, 0)) | ||
|
||
arg: Record<string, (arg: string) => void> | Array<(arg: number) => void> | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts, 2, 22)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts, 3, 23)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts, 3, 54)) | ||
|
||
): void; | ||
|
||
test([ | ||
>test : Symbol(test, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts, 0, 0)) | ||
|
||
(arg) => { | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts, 7, 3)) | ||
|
||
arg; // number | ||
>arg : Symbol(arg, Decl(contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts, 7, 3)) | ||
|
||
}, | ||
]); | ||
|
28 changes: 28 additions & 0 deletions
28
.../baselines/reference/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.types
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,28 @@ | ||
=== tests/cases/compiler/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts === | ||
// repro from #52588 | ||
|
||
declare function test( | ||
>test : (arg: Record<string, (arg: string) => void> | ((arg: number) => void)[]) => void | ||
|
||
arg: Record<string, (arg: string) => void> | Array<(arg: number) => void> | ||
>arg : Record<string, (arg: string) => void> | ((arg: number) => void)[] | ||
>arg : string | ||
>arg : number | ||
|
||
): void; | ||
|
||
test([ | ||
>test([ (arg) => { arg; // number },]) : void | ||
>test : (arg: Record<string, (arg: string) => void> | ((arg: number) => void)[]) => void | ||
>[ (arg) => { arg; // number },] : ((arg: number) => void)[] | ||
|
||
(arg) => { | ||
>(arg) => { arg; // number } : (arg: number) => void | ||
>arg : number | ||
|
||
arg; // number | ||
>arg : 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
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
15 changes: 15 additions & 0 deletions
15
tests/cases/compiler/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs2015.ts
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,15 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
// @lib: es2015 | ||
|
||
// repro from #52588 | ||
|
||
declare function test( | ||
arg: Record<string, (arg: string) => void> | Array<(arg: number) => void> | ||
): void; | ||
|
||
test([ | ||
(arg) => { | ||
arg; // number | ||
}, | ||
]); |
15 changes: 15 additions & 0 deletions
15
tests/cases/compiler/contextualSignatureInArrayElementPrefersArrayUnionMemberLibEs5.ts
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,15 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
// @lib: es5 | ||
|
||
// repro from #52588 | ||
|
||
declare function test( | ||
arg: Record<string, (arg: string) => void> | Array<(arg: number) => void> | ||
): void; | ||
|
||
test([ | ||
(arg) => { | ||
arg; // 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