Check nested weak types in intersections on target side of relation#51140
Check nested weak types in intersections on target side of relation#51140ahejlsberg merged 5 commits intomainfrom
Conversation
|
@typescript-bot test this |
|
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 72a0f3b. You can monitor the build here. Update: The results are in! |
|
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 72a0f3b. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 72a0f3b. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at 72a0f3b. You can monitor the build here. Update: The results are in! |
|
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 72a0f3b. You can monitor the build here. Update: The results are in! |
|
@ahejlsberg Here are the results of running the user test suite comparing Everything looks good! |
|
@ahejlsberg Here they are:Comparison Report - main..51140
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@ahejlsberg Here are the results of running the top-repos suite comparing Everything looks good! |
|
@typescript-bot test this |
|
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at f0f853e. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at f0f853e. You can monitor the build here. Update: The results are in! |
|
Heya @ahejlsberg, I've started to run the extended test suite on this PR at f0f853e. You can monitor the build here. |
|
Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at f0f853e. You can monitor the build here. Update: The results are in! |
|
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at f0f853e. You can monitor the build here. Update: The results are in! |
|
@ahejlsberg Here are the results of running the user test suite comparing Everything looks good! |
|
@ahejlsberg Here they are:Comparison Report - main..51140
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@ahejlsberg Here are the results of running the top-repos suite comparing Everything looks good! |
| } | ||
|
|
||
| const isPerformingCommonPropertyChecks = (relation !== comparableRelation || !(source.flags & TypeFlags.Union) && isLiteralType(source)) && | ||
| const isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) && |
There was a problem hiding this comment.
I believe the problem with isUnitType is that it doesn't consider enum literal types.
https://github.com/microsoft/TypeScript/pull/50423/files#r954112029
So we won't catch assignability from an enum literal to a weak type with no overlap.
enum E { A = "A" }
// these will differ
let x: { nope?: any } = E.A;
let y: { nope?: any } = "A";There was a problem hiding this comment.
Enum literal types are definitely considered unit types. It's a bit subtle, isUnitType checks for TypeFlags.Unit, which includes TypeFlags.Literal, which includes TypeFlags.StringLiteral and TypeFlags.NumberLiteral. For enum literal types, the TypeFlags.EnumLiteral flag is always combined with one of the latter two, so isUnitType will always be true.
There was a problem hiding this comment.
Just to be sure, I verified both of your examples generate errors.
There was a problem hiding this comment.
Great! Can you add that as a test case?
Fixes #51043.
This PR also moves some intersection property check logic from
isRelatedTotostructuredTypeRelatedTo(i.e. from the un-cached to the cached side of relationship checking). This allows us to get rid of a separate cache lookup and two associatedIntersectionStateflags.