Don't use a cached union/intersection type if there is an aliasSymbol#17349
Closed
Don't use a cached union/intersection type if there is an aliasSymbol#17349
Conversation
86ea47f to
af108c0
Compare
af108c0 to
82d68fc
Compare
sandersn
reviewed
Jul 25, 2017
| @@ -1,32 +1,32 @@ | |||
| === tests/cases/conformance/types/literal/booleanLiteralTypes1.ts === | |||
| type A1 = true | false; | |||
| >A1 : boolean | |||
Member
There was a problem hiding this comment.
This behaviour is intended. I don't know that it's super important. It's probably even less important that
type A = { a }
type B = { b }
type T = A | B
type U = A | B
declare var t: T
declare var u: Ushould also print either T or U (or A | B) for both t and u.
It's more important that:
declare var x: true | falseprints 'boolean' for the type of x
Member
There was a problem hiding this comment.
@ahejlsberg can you weigh in on true | false and boolean being equivalent to type B = true | false ?
ghost
commented
Jul 25, 2017
|
|
||
| var a: false | true; | ||
| >a : boolean | ||
| >a : A1 |
Author
There was a problem hiding this comment.
This change looked wrong until I realized that this is the fourth declaration of a, and the first declaration has type A1, which is the type shown here.
There is a test below showing that a variable whose only declaration is of type true | false will still print as boolean.
Member
This was referenced Jul 26, 2017
Author
|
Closing in favor of #17434. |
This pull request was closed.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
It's not safe to cache the creation of a value based on only some of the inputs to that creation. This updates the code to not cache the creation of a type alias with
aliasSymboldefined. (Presumably we will never create a type for the same symbol twice?)