Allow weak type detection for intersection sources (#26668)

Previously, intersections were only allowed as targets, but this was
just an artifact of the original implementation, which operated inside
the structural part of isRelatedTo. Removing this restriction catches
subtle bugs in React user code, where a function named `create` returns
a mapped type whose types are all branded numbers. The display of these
properties, for some original type `T`, is not `number & { __ }` but
the much-less-obvious `RegisteredStyle<T>`.
This commit is contained in:
Nathan Shively-Sanders
2018-08-24 10:30:39 -07:00
committed by GitHub
parent bdb7c351a2
commit 0043ba16b1
6 changed files with 207 additions and 1 deletions

View File

@@ -11178,7 +11178,7 @@ namespace ts {
}
if (relation !== comparableRelation &&
!(source.flags & TypeFlags.UnionOrIntersection) &&
!(source.flags & TypeFlags.Union) &&
!(target.flags & TypeFlags.Union) &&
!isIntersectionConstituent &&
source !== globalObjectType &&