Skip to content
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

Preserve type aliases for union and intersection types #42149

Merged
merged 32 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8f2e00f
Create separate types for equivalent aliased unions
ahejlsberg Dec 25, 2020
1e9ea77
Accept new baselines
ahejlsberg Dec 25, 2020
c9bea0c
Preserve original types for union types
ahejlsberg Dec 28, 2020
2e2048c
Accept new baselines
ahejlsberg Dec 28, 2020
44231c8
Preserve intersection origin for union types
ahejlsberg Dec 29, 2020
829285f
Accept new baselines
ahejlsberg Dec 29, 2020
536e41e
Accept new baselines
ahejlsberg Dec 29, 2020
cc5d0f2
Preserve aliases during relationship checks
ahejlsberg Dec 29, 2020
b2434fc
Accept new baselines
ahejlsberg Dec 29, 2020
6c1248e
Preserve aliases for intersection and indexed access types
ahejlsberg Dec 29, 2020
237e9ca
Accept new baselines
ahejlsberg Dec 29, 2020
d4dc215
Compute intersection-of-unions cross product without recursion
ahejlsberg Dec 30, 2020
11d2712
Accept new baselines
ahejlsberg Dec 30, 2020
39f82a8
Use denormalized type objects for origin / support 'keyof' origins
ahejlsberg Jan 1, 2021
d9a0f50
Accept new baselines
ahejlsberg Jan 1, 2021
e0d4774
Fix fourslash test
ahejlsberg Jan 1, 2021
21f61c0
Recursively extract named union types
ahejlsberg Jan 2, 2021
785d2b7
Accept new baselines
ahejlsberg Jan 2, 2021
d98caab
Map on union origin in mapType to better preserve aliases and origins
ahejlsberg Jan 3, 2021
260a665
Remove redundant call
ahejlsberg Jan 4, 2021
8597325
Accept new baselines
ahejlsberg Jan 4, 2021
5f7e126
Revert back to declared type when branches produce equivalent union
ahejlsberg Jan 4, 2021
8ef90e7
Accept new baselines
ahejlsberg Jan 4, 2021
4c9675c
Merge branch 'master' into preserveTypeAliases
ahejlsberg Jan 4, 2021
3fce1b9
Don't include denormal origin types in regular type statistics
ahejlsberg Jan 4, 2021
99355c5
Merge branch 'master' into preserveTypeAliases
ahejlsberg Jan 5, 2021
e388a26
Fix issue with unions not being marked primitive-only
ahejlsberg Jan 5, 2021
2c2d06d
Allow new alias to be associated with type alias instantiation
ahejlsberg Jan 8, 2021
4507270
Accept new baselines
ahejlsberg Jan 8, 2021
e794cb9
Merge branch 'master' into preserveTypeAliases
ahejlsberg Jan 8, 2021
4e123f5
Revert "Accept new baselines"
ahejlsberg Jan 9, 2021
8881f01
Revert "Allow new alias to be associated with type alias instantiation"
ahejlsberg Jan 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Dec 30, 2020
commit 11d2712437c3a98ac0a4ddb913556dfb56678e1b
32 changes: 16 additions & 16 deletions tests/baselines/reference/intersectionAndUnionTypes.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(28,1): e
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'.
Type 'A & B' is not assignable to type 'C | D'.
Property 'd' is missing in type 'A & B' but required in type 'D'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'.
Type 'A & B' is not assignable to type 'B & D'.
Property 'd' is missing in type 'A & B' but required in type 'D'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
Type 'A' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'.
Type 'A' is not assignable to type '(A | B) & (C | D)'.
Type 'A' is not assignable to type 'A & D'.
Property 'd' is missing in type 'A' but required in type 'D'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'.
Type 'C & D' is not assignable to type 'B & D'.
Property 'b' is missing in type 'C & D' but required in type 'B'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
Type 'C' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'.
Type 'C' is not assignable to type '(A | B) & (C | D)'.
Type 'C' is not assignable to type 'B & C'.
Property 'b' is missing in type 'C' but required in type 'B'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'A & B'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'.
Type 'A & C' is not assignable to type 'A & B'.
Property 'b' is missing in type 'A & C' but required in type 'B'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'C & D'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'.
Type 'A & C' is not assignable to type 'C & D'.
Property 'd' is missing in type 'A & C' but required in type 'D'.

Expand Down Expand Up @@ -116,40 +116,40 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e

y = anb;
~
!!! error TS2322: Type 'A & B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
!!! error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'A & B' is not assignable to type 'B & D'.
!!! error TS2322: Property 'd' is missing in type 'A & B' but required in type 'D'.
!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:4:15: 'd' is declared here.
y = aob;
~
!!! error TS2322: Type 'A | B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
!!! error TS2322: Type 'A' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
!!! error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'A' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'A' is not assignable to type 'A & D'.
!!! error TS2322: Property 'd' is missing in type 'A' but required in type 'D'.
!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:4:15: 'd' is declared here.
y = cnd;
~
!!! error TS2322: Type 'C & D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
!!! error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'C & D' is not assignable to type 'B & D'.
!!! error TS2322: Property 'b' is missing in type 'C & D' but required in type 'B'.
!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:2:15: 'b' is declared here.
y = cod;
~
!!! error TS2322: Type 'C | D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
!!! error TS2322: Type 'C' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'.
!!! error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'C' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'C' is not assignable to type 'B & C'.
!!! error TS2322: Property 'b' is missing in type 'C' but required in type 'B'.
!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:2:15: 'b' is declared here.
anb = y;
~~~
!!! error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'A & B'.
!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'.
!!! error TS2322: Type 'A & C' is not assignable to type 'A & B'.
!!! error TS2322: Property 'b' is missing in type 'A & C' but required in type 'B'.
!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:2:15: 'b' is declared here.
aob = y; // Ok
cnd = y;
~~~
!!! error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'C & D'.
!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'.
!!! error TS2322: Type 'A & C' is not assignable to type 'C & D'.
!!! error TS2322: Property 'd' is missing in type 'A & C' but required in type 'D'.
!!! related TS2728 tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts:4:15: 'd' is declared here.
Expand Down
26 changes: 13 additions & 13 deletions tests/baselines/reference/intersectionAndUnionTypes.types
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var x: A & B | C & D;
>x : (A & B) | (C & D)

var y: (A | B) & (C | D);
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)

a = anb; // Ok
>a = anb : A & B
Expand Down Expand Up @@ -103,41 +103,41 @@ cod = x;

y = anb;
>y = anb : A & B
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)
>anb : A & B

y = aob;
>y = aob : A | B
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)
>aob : A | B

y = cnd;
>y = cnd : C & D
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)
>cnd : C & D

y = cod;
>y = cod : C | D
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)
>cod : C | D

anb = y;
>anb = y : (A & C) | (A & D) | (B & C) | (B & D)
>anb = y : (A | B) & (C | D)
>anb : A & B
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)

aob = y; // Ok
>aob = y : (A & C) | (A & D) | (B & C) | (B & D)
>aob = y : (A | B) & (C | D)
>aob : A | B
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)

cnd = y;
>cnd = y : (A & C) | (A & D) | (B & C) | (B & D)
>cnd = y : (A | B) & (C | D)
>cnd : C & D
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)

cod = y; // Ok
>cod = y : (A & C) | (A & D) | (B & C) | (B & D)
>cod = y : (A | B) & (C | D)
>cod : C | D
>y : (A & C) | (A & D) | (B & C) | (B & D)
>y : (A | B) & (C | D)

6 changes: 3 additions & 3 deletions tests/baselines/reference/unionTypeCallSignatures.types
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ strOrBoolean = unionOfDifferentReturnType("hello"); // error
>"hello" : "hello"

unionOfDifferentReturnType1(true); // error in type of parameter
>unionOfDifferentReturnType1(true) : (Date & string) | (Date & false) | (Date & true)
>unionOfDifferentReturnType1(true) : (number | Date) & (string | boolean)
>unionOfDifferentReturnType1 : { (a: number): number; (a: string): string; } | { (a: number): Date; (a: string): boolean; }
>true : true

Expand All @@ -56,12 +56,12 @@ strOrBoolean = unionOfDifferentReturnType1("hello");
>"hello" : "hello"

unionOfDifferentReturnType1(true); // error in type of parameter
>unionOfDifferentReturnType1(true) : (Date & string) | (Date & false) | (Date & true)
>unionOfDifferentReturnType1(true) : (number | Date) & (string | boolean)
>unionOfDifferentReturnType1 : { (a: number): number; (a: string): string; } | { (a: number): Date; (a: string): boolean; }
>true : true

unionOfDifferentReturnType1(); // error missing parameter
>unionOfDifferentReturnType1() : (Date & string) | (Date & false) | (Date & true)
>unionOfDifferentReturnType1() : (number | Date) & (string | boolean)
>unionOfDifferentReturnType1 : { (a: number): number; (a: string): string; } | { (a: number): Date; (a: string): boolean; }

var unionOfDifferentParameterTypes: { (a: number): number; } | { (a: string): Date; };
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/unionTypeConstructSignatures.types
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ strOrBoolean = new unionOfDifferentReturnType("hello"); // error
>"hello" : "hello"

new unionOfDifferentReturnType1(true); // error in type of parameter
>new unionOfDifferentReturnType1(true) : (Date & string) | (Date & false) | (Date & true)
>new unionOfDifferentReturnType1(true) : (number | Date) & (string | boolean)
>unionOfDifferentReturnType1 : { new (a: number): number; new (a: string): string; } | { new (a: number): Date; new (a: string): boolean; }
>true : true

Expand All @@ -56,12 +56,12 @@ strOrBoolean = new unionOfDifferentReturnType1("hello");
>"hello" : "hello"

new unionOfDifferentReturnType1(true); // error in type of parameter
>new unionOfDifferentReturnType1(true) : (Date & string) | (Date & false) | (Date & true)
>new unionOfDifferentReturnType1(true) : (number | Date) & (string | boolean)
>unionOfDifferentReturnType1 : { new (a: number): number; new (a: string): string; } | { new (a: number): Date; new (a: string): boolean; }
>true : true

new unionOfDifferentReturnType1(); // error missing parameter
>new unionOfDifferentReturnType1() : (Date & string) | (Date & false) | (Date & true)
>new unionOfDifferentReturnType1() : (number | Date) & (string | boolean)
>unionOfDifferentReturnType1 : { new (a: number): number; new (a: string): string; } | { new (a: number): Date; new (a: string): boolean; }

var unionOfDifferentParameterTypes: { new (a: number): number; } | { new (a: string): Date; };
Expand Down