-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Component commits: 4635cdc Forward intersection state flag to conditional type target check Co-authored-by: Andrew Branch <[email protected]>
- Loading branch information
1 parent
ca022ae
commit 6bb16f1
Showing
5 changed files
with
56 additions
and
2 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
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/excessPropertyCheckingIntersectionWithConditional.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,10 @@ | ||
//// [excessPropertyCheckingIntersectionWithConditional.ts] | ||
type Foo<K> = K extends unknown ? { a: number } : unknown | ||
const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => { | ||
return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2 | ||
} | ||
|
||
//// [excessPropertyCheckingIntersectionWithConditional.js] | ||
var createDefaultExample = function (x) { | ||
return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2 | ||
}; |
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/excessPropertyCheckingIntersectionWithConditional.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,22 @@ | ||
=== tests/cases/compiler/excessPropertyCheckingIntersectionWithConditional.ts === | ||
type Foo<K> = K extends unknown ? { a: number } : unknown | ||
>Foo : Symbol(Foo, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 0)) | ||
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 9)) | ||
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 9)) | ||
>a : Symbol(a, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 35)) | ||
|
||
const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => { | ||
>createDefaultExample : Symbol(createDefaultExample, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 5)) | ||
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30)) | ||
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 34)) | ||
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30)) | ||
>Foo : Symbol(Foo, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 0, 0)) | ||
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30)) | ||
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 51)) | ||
>K : Symbol(K, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 30)) | ||
|
||
return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2 | ||
>a : Symbol(a, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 2, 10)) | ||
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 2, 16)) | ||
>x : Symbol(x, Decl(excessPropertyCheckingIntersectionWithConditional.ts, 1, 34)) | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/excessPropertyCheckingIntersectionWithConditional.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,18 @@ | ||
=== tests/cases/compiler/excessPropertyCheckingIntersectionWithConditional.ts === | ||
type Foo<K> = K extends unknown ? { a: number } : unknown | ||
>Foo : Foo<K> | ||
>a : number | ||
|
||
const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => { | ||
>createDefaultExample : <K>(x: K) => Foo<K> & { x: K; } | ||
><K,>(x: K): Foo<K> & { x: K; } => { return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2} : <K>(x: K) => Foo<K> & { x: K; } | ||
>x : K | ||
>x : K | ||
|
||
return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2 | ||
>{ a: 1, x: x } : { a: number; x: K; } | ||
>a : number | ||
>1 : 1 | ||
>x : K | ||
>x : K | ||
} |
4 changes: 4 additions & 0 deletions
4
tests/cases/compiler/excessPropertyCheckingIntersectionWithConditional.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,4 @@ | ||
type Foo<K> = K extends unknown ? { a: number } : unknown | ||
const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => { | ||
return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2 | ||
} |