-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce intersections by discriminants #36696
Changes from 19 commits
ace0904
eaf872c
94353d2
346ec30
acd3fec
7ae4a21
3a1ba48
e1434a5
37c6280
dba1043
f170191
6b2f3a2
aeab6af
4f67910
49302f2
aa8d227
8907e92
04facee
88be5ea
fbf13dc
85447a5
7741085
d2b3807
6590e20
40340ae
c4c1418
8eb08e8
874938c
ede9d01
42022f3
e24b250
12f6224
a015ab9
95ecb7b
b99b9b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,9 @@ tests/cases/conformance/types/union/discriminatedUnionTypes2.ts(27,30): error TS | |
Object literal may only specify known properties, and 'c' does not exist in type '{ a: null; b: string; }'. | ||
tests/cases/conformance/types/union/discriminatedUnionTypes2.ts(32,11): error TS2339: Property 'b' does not exist on type '{ a: 0; b: string; } | { a: T; c: number; }'. | ||
Property 'b' does not exist on type '{ a: T; c: number; }'. | ||
tests/cases/conformance/types/union/discriminatedUnionTypes2.ts(132,11): error TS2339: Property 'value' does not exist on type 'never'. | ||
|
||
|
||
==== tests/cases/conformance/types/union/discriminatedUnionTypes2.ts (3 errors) ==== | ||
==== tests/cases/conformance/types/union/discriminatedUnionTypes2.ts (2 errors) ==== | ||
function f10(x : { kind: false, a: string } | { kind: true, b: string } | { kind: string, c: string }) { | ||
if (x.kind === false) { | ||
x.a; | ||
|
@@ -144,8 +143,6 @@ tests/cases/conformance/types/union/discriminatedUnionTypes2.ts(132,11): error T | |
} | ||
else { | ||
x.value; // Error, x is never | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not an error anymore, it seems There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an expected effect. After reducing away empty intersections, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant that the comment is outdated now |
||
~~~~~ | ||
!!! error TS2339: Property 'value' does not exist on type 'never'. | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,6 @@ if (!hasKind(x, "B")) { | |
} | ||
else { | ||
let d = x; | ||
>d : A & B | ||
>x : A & B | ||
>d : never | ||
>x : never | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,6 @@ if (!hasKind(x, "B")) { | |
} | ||
else { | ||
let d = x; | ||
>d : A & B | ||
>x : A & B | ||
>d : never | ||
>x : never | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,6 @@ if (!hasKind(x, "B")) { | |
} | ||
else { | ||
let d = x; | ||
>d : A & B | ||
>x : A & B | ||
>d : never | ||
>x : never | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts(7,20): error TS2339: Property 'global' does not exist on type 'never'. | ||
|
||
|
||
==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts (1 errors) ==== | ||
interface I { global: string; } | ||
var result: I; | ||
var result2: I; | ||
|
||
if (!(result instanceof RegExp)) { | ||
result = result2; | ||
} else if (!result.global) { | ||
~~~~~~ | ||
!!! error TS2339: Property 'global' does not exist on type 'never'. | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? Related?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what your question is here? With the improved precision of intersections, the checker was proving that this expression could never be true.