File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -44158,15 +44158,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4415844158 getNodeLinks(narrowReference).resolvedSymbol = symbol;
4415944159 setParent(narrowReference, narrowPosition.parent);
4416044160 setNodeFlags(narrowReference, narrowReference.flags | NodeFlags.Synthesized);
44161- // >> TODO: get rid of this cast?
4416244161 narrowReference.flowNode = narrowPosition.flowNode;
4416344162 const exprType = getTypeOfExpression(narrowReference);
44163+ // Try to detect if the type of the reference was not narrowed.
4416444164 // >> TODO: is there a better way of detecting that narrowing will be useless?
44165- if (getConstraintOfTypeParameter(tp)) {
44166- const narrowableConstraintType = mapType(tp.constraint!, getBaseConstraintOrType);
44167- if (narrowableConstraintType === exprType) {
44168- return undefined; // Don't narrow if narrowing didn't do anything but default to constraints
44169- }
44165+ if (exprType === tp || exprType === mapType(tp, getBaseConstraintOrType)) {
44166+ return undefined; // Don't narrow if narrowing didn't do anything but default to the type parameter or its constraint.
4417044167 }
4417144168 return [tp, exprType];
4417244169 });
You can’t perform that action at this time.
0 commit comments