-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Remove redundant primitive types from intersections #23751
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
Changes from 4 commits
d25a6ec
cfe7284
38d1f7f
e80b47d
5a7eb1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [intersectionReduction.ts] | ||
// @strict | ||
|
||
declare const sym1: unique symbol; | ||
declare const sym2: unique symbol; | ||
|
||
type T1 = string & 'a'; // 'a' | ||
type T2 = 'a' & string & 'b'; // 'a' & 'b' | ||
type T3 = number & 10; // 10 | ||
type T4 = 10 & number & 20; // 10 & 20 | ||
type T5 = symbol & typeof sym1; // typeof sym1 | ||
type T6 = typeof sym1 & symbol & typeof sym2; // typeof sym1 & typeof sym2 | ||
type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // 'a' & 10 & typeof sym1 | ||
|
||
type T10 = string & ('a' | 'b'); // 'a' | 'b' | ||
type T11 = (string | number) & ('a' | 10); // 'a' | 10 | ||
|
||
|
||
//// [intersectionReduction.js] | ||
// @strict |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
=== tests/cases/conformance/types/intersection/intersectionReduction.ts === | ||
// @strict | ||
|
||
declare const sym1: unique symbol; | ||
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) | ||
|
||
declare const sym2: unique symbol; | ||
>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 3, 13)) | ||
|
||
type T1 = string & 'a'; // 'a' | ||
>T1 : Symbol(T1, Decl(intersectionReduction.ts, 3, 34)) | ||
|
||
type T2 = 'a' & string & 'b'; // 'a' & 'b' | ||
>T2 : Symbol(T2, Decl(intersectionReduction.ts, 5, 23)) | ||
|
||
type T3 = number & 10; // 10 | ||
>T3 : Symbol(T3, Decl(intersectionReduction.ts, 6, 29)) | ||
|
||
type T4 = 10 & number & 20; // 10 & 20 | ||
>T4 : Symbol(T4, Decl(intersectionReduction.ts, 7, 22)) | ||
|
||
type T5 = symbol & typeof sym1; // typeof sym1 | ||
>T5 : Symbol(T5, Decl(intersectionReduction.ts, 8, 27)) | ||
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) | ||
|
||
type T6 = typeof sym1 & symbol & typeof sym2; // typeof sym1 & typeof sym2 | ||
>T6 : Symbol(T6, Decl(intersectionReduction.ts, 9, 31)) | ||
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) | ||
>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 3, 13)) | ||
|
||
type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // 'a' & 10 & typeof sym1 | ||
>T7 : Symbol(T7, Decl(intersectionReduction.ts, 10, 45)) | ||
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) | ||
|
||
type T10 = string & ('a' | 'b'); // 'a' | 'b' | ||
>T10 : Symbol(T10, Decl(intersectionReduction.ts, 11, 60)) | ||
|
||
type T11 = (string | number) & ('a' | 10); // 'a' | 10 | ||
>T11 : Symbol(T11, Decl(intersectionReduction.ts, 13, 32)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
=== tests/cases/conformance/types/intersection/intersectionReduction.ts === | ||
// @strict | ||
|
||
declare const sym1: unique symbol; | ||
>sym1 : unique symbol | ||
|
||
declare const sym2: unique symbol; | ||
>sym2 : unique symbol | ||
|
||
type T1 = string & 'a'; // 'a' | ||
>T1 : "a" | ||
|
||
type T2 = 'a' & string & 'b'; // 'a' & 'b' | ||
>T2 : T2 | ||
|
||
type T3 = number & 10; // 10 | ||
>T3 : 10 | ||
|
||
type T4 = 10 & number & 20; // 10 & 20 | ||
>T4 : T4 | ||
|
||
type T5 = symbol & typeof sym1; // typeof sym1 | ||
>T5 : unique symbol | ||
>sym1 : unique symbol | ||
|
||
type T6 = typeof sym1 & symbol & typeof sym2; // typeof sym1 & typeof sym2 | ||
>T6 : T6 | ||
>sym1 : unique symbol | ||
>sym2 : unique symbol | ||
|
||
type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // 'a' & 10 & typeof sym1 | ||
>T7 : T7 | ||
>sym1 : unique symbol | ||
|
||
type T10 = string & ('a' | 'b'); // 'a' | 'b' | ||
>T10 : "a" | "b" | ||
|
||
type T11 = (string | number) & ('a' | 10); // 'a' | 10 | ||
>T11 : "a" | 10 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// @strict | ||
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.
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 don't think so. We have hundreds of tests that include 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 comment isn't |
||
|
||
declare const sym1: unique symbol; | ||
declare const sym2: unique symbol; | ||
|
||
type T1 = string & 'a'; // 'a' | ||
type T2 = 'a' & string & 'b'; // 'a' & 'b' | ||
type T3 = number & 10; // 10 | ||
type T4 = 10 & number & 20; // 10 & 20 | ||
type T5 = symbol & typeof sym1; // typeof sym1 | ||
type T6 = typeof sym1 & symbol & typeof sym2; // typeof sym1 & typeof sym2 | ||
type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // 'a' & 10 & typeof sym1 | ||
|
||
type T10 = string & ('a' | 'b'); // 'a' | 'b' | ||
type T11 = (string | number) & ('a' | 10); // 'a' | 10 |
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.
Typo: should be
removeRedundantPrimitiveTypes