(source, target)
| 71226 | // Filter out types that are not considered to be "constructed by" the `candidate` type. |
| 71227 | return filterType(type, function (t) { return isConstructedBy(t, candidate); }); |
| 71228 | function isConstructedBy(source, target) { |
| 71229 | // If either the source or target type are a class type then we need to check that they are the same exact type. |
| 71230 | // This is because you may have a class `A` that defines some set of properties, and another class `B` |
| 71231 | // that defines the same set of properties as class `A`, in that case they are structurally the same |
| 71232 | // type, but when you do something like `instanceOfA.constructor === B` it will return false. |
| 71233 | if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || |
| 71234 | target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { |
| 71235 | return source.symbol === target.symbol; |
| 71236 | } |
| 71237 | // For all other types just check that the `source` type is a subtype of the `target` type. |
| 71238 | return isTypeSubtypeOf(source, target); |
| 71239 | } |
| 71240 | } |
| 71241 | function narrowTypeByInstanceof(type, expr, assumeTrue) { |
| 71242 | var left = getReferenceCandidate(expr.left); |
no test coverage detected
searching dependent graphs…