-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Preserve type aliases for union and intersection types #42149
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
Merged
+1,071
−958
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
8f2e00f
Create separate types for equivalent aliased unions
ahejlsberg 1e9ea77
Accept new baselines
ahejlsberg c9bea0c
Preserve original types for union types
ahejlsberg 2e2048c
Accept new baselines
ahejlsberg 44231c8
Preserve intersection origin for union types
ahejlsberg 829285f
Accept new baselines
ahejlsberg 536e41e
Accept new baselines
ahejlsberg cc5d0f2
Preserve aliases during relationship checks
ahejlsberg b2434fc
Accept new baselines
ahejlsberg 6c1248e
Preserve aliases for intersection and indexed access types
ahejlsberg 237e9ca
Accept new baselines
ahejlsberg d4dc215
Compute intersection-of-unions cross product without recursion
ahejlsberg 11d2712
Accept new baselines
ahejlsberg 39f82a8
Use denormalized type objects for origin / support 'keyof' origins
ahejlsberg d9a0f50
Accept new baselines
ahejlsberg e0d4774
Fix fourslash test
ahejlsberg 21f61c0
Recursively extract named union types
ahejlsberg 785d2b7
Accept new baselines
ahejlsberg d98caab
Map on union origin in mapType to better preserve aliases and origins
ahejlsberg 260a665
Remove redundant call
ahejlsberg 8597325
Accept new baselines
ahejlsberg 5f7e126
Revert back to declared type when branches produce equivalent union
ahejlsberg 8ef90e7
Accept new baselines
ahejlsberg 4c9675c
Merge branch 'master' into preserveTypeAliases
ahejlsberg 3fce1b9
Don't include denormal origin types in regular type statistics
ahejlsberg 99355c5
Merge branch 'master' into preserveTypeAliases
ahejlsberg e388a26
Fix issue with unions not being marked primitive-only
ahejlsberg 2c2d06d
Allow new alias to be associated with type alias instantiation
ahejlsberg 4507270
Accept new baselines
ahejlsberg e794cb9
Merge branch 'master' into preserveTypeAliases
ahejlsberg 4e123f5
Revert "Accept new baselines"
ahejlsberg 8881f01
Revert "Allow new alias to be associated with type alias instantiation"
ahejlsberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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 |
---|---|---|
@@ -1,30 +1,30 @@ | ||
=== tests/cases/conformance/types/literal/booleanLiteralTypes1.ts === | ||
type A1 = true | false; | ||
>A1 : boolean | ||
>A1 : A1 | ||
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. Is this just a bug in our type writer for tests, or is this what quickinfo would show as well (i.e., |
||
>true : true | ||
>false : false | ||
|
||
type A2 = false | true; | ||
>A2 : boolean | ||
>A2 : A2 | ||
>false : false | ||
>true : true | ||
|
||
function f1() { | ||
>f1 : () => void | ||
|
||
var a: A1; | ||
>a : boolean | ||
>a : A1 | ||
|
||
var a: A2; | ||
>a : boolean | ||
>a : A1 | ||
|
||
var a: true | false; | ||
>a : boolean | ||
>a : A1 | ||
>true : true | ||
>false : false | ||
|
||
var a: false | true; | ||
>a : boolean | ||
>a : A1 | ||
>false : false | ||
>true : true | ||
} | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is another interesting case where the alias is no longer preserved. I assume this is because of the bug that we'd use a type alias name when we encountered a union with the same constituents? I'd guess this is the correct type representation, since the type of
good.type
comes from the union ofILinearAxis["type"]
andICategoricalAxis["type"]
, which wouldn't have an origin.