Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30801 from Microsoft/tweakUnionTypeInference
Tweak union type inference
- Loading branch information
Showing
5 changed files
with
74 additions
and
7 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
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/unionAndIntersectionInference3.js
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 @@ | ||
//// [unionAndIntersectionInference3.ts] | ||
// Repro from #30720 | ||
|
||
type Maybe<T> = T | undefined; | ||
declare function concatMaybe<T>(...args: (Maybe<T> | Maybe<T>[])[]): T[]; | ||
concatMaybe([1, 2, 3], 4); | ||
|
||
|
||
//// [unionAndIntersectionInference3.js] | ||
"use strict"; | ||
// Repro from #30720 | ||
concatMaybe([1, 2, 3], 4); |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/unionAndIntersectionInference3.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,21 @@ | ||
=== tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts === | ||
// Repro from #30720 | ||
|
||
type Maybe<T> = T | undefined; | ||
>Maybe : Symbol(Maybe, Decl(unionAndIntersectionInference3.ts, 0, 0)) | ||
>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 2, 11)) | ||
>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 2, 11)) | ||
|
||
declare function concatMaybe<T>(...args: (Maybe<T> | Maybe<T>[])[]): T[]; | ||
>concatMaybe : Symbol(concatMaybe, Decl(unionAndIntersectionInference3.ts, 2, 30)) | ||
>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 3, 29)) | ||
>args : Symbol(args, Decl(unionAndIntersectionInference3.ts, 3, 32)) | ||
>Maybe : Symbol(Maybe, Decl(unionAndIntersectionInference3.ts, 0, 0)) | ||
>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 3, 29)) | ||
>Maybe : Symbol(Maybe, Decl(unionAndIntersectionInference3.ts, 0, 0)) | ||
>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 3, 29)) | ||
>T : Symbol(T, Decl(unionAndIntersectionInference3.ts, 3, 29)) | ||
|
||
concatMaybe([1, 2, 3], 4); | ||
>concatMaybe : Symbol(concatMaybe, Decl(unionAndIntersectionInference3.ts, 2, 30)) | ||
|
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/unionAndIntersectionInference3.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,19 @@ | ||
=== tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.ts === | ||
// Repro from #30720 | ||
|
||
type Maybe<T> = T | undefined; | ||
>Maybe : Maybe<T> | ||
|
||
declare function concatMaybe<T>(...args: (Maybe<T> | Maybe<T>[])[]): T[]; | ||
>concatMaybe : <T>(...args: (T | Maybe<T>[] | undefined)[]) => T[] | ||
>args : (T | Maybe<T>[] | undefined)[] | ||
|
||
concatMaybe([1, 2, 3], 4); | ||
>concatMaybe([1, 2, 3], 4) : number[] | ||
>concatMaybe : <T>(...args: (T | Maybe<T>[] | undefined)[]) => T[] | ||
>[1, 2, 3] : number[] | ||
>1 : 1 | ||
>2 : 2 | ||
>3 : 3 | ||
>4 : 4 | ||
|
7 changes: 7 additions & 0 deletions
7
...cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference3.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,7 @@ | ||
// @strict: true | ||
|
||
// Repro from #30720 | ||
|
||
type Maybe<T> = T | undefined; | ||
declare function concatMaybe<T>(...args: (Maybe<T> | Maybe<T>[])[]): T[]; | ||
concatMaybe([1, 2, 3], 4); |