Skip to content

Commit bb87332

Browse files
committed
Add more comments
1 parent 00f41e5 commit bb87332

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15516,6 +15516,10 @@ namespace ts {
1551615516
}
1551715517
}
1551815518
else if (target.flags & TypeFlags.Intersection && some((<IntersectionType>target).types, t => !!getInferenceInfoForType(t))) {
15519+
// We reduce intersection types only when they contain naked type parameters. For example, when
15520+
// inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and
15521+
// infer { extra: any } for T. But when inferring to 'string[] & Iterable<T>' we want to keep the
15522+
// string[] on the source side and infer string for T.
1551915523
if (source.flags & TypeFlags.Intersection) {
1552015524
// Infer between identically matching source and target constituents and remove the matching types.
1552115525
const [sources, targets] = inferFromMatchingTypes((<IntersectionType>source).types, (<IntersectionType>target).types, isTypeIdenticalTo);

0 commit comments

Comments
 (0)