@@ -37435,11 +37435,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37435
37435
antecedent,
37436
37436
};
37437
37437
37438
- const paramId = getIdentifierForParam(param);
37439
- if (!paramId) {
37440
- continue;
37441
- }
37442
- const narrowedParamTypeTrue = getFlowTypeOfReference(paramId, initType, initType, func, trueCondition);
37438
+ const narrowedParamTypeTrue = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
37443
37439
if (narrowedParamTypeTrue === initType) {
37444
37440
continue;
37445
37441
}
@@ -37451,7 +37447,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37451
37447
...trueCondition,
37452
37448
flags: FlowFlags.FalseCondition | FlowFlags.Referenced | FlowFlags.Shared,
37453
37449
}
37454
- const narrowedParamTypeFalse = getFlowTypeOfReference(paramId , initType, initType, func, falseCondition);
37450
+ const narrowedParamTypeFalse = getFlowTypeOfReference(param.name , initType, initType, func, falseCondition);
37455
37451
// It's safe to infer a type guard if:
37456
37452
// narrowedParamTypeFalse = Exclude<initType, narrowedParamTypeTrue>
37457
37453
// what's the difference between a subtype and assignable relationship?
@@ -37463,18 +37459,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37463
37459
}
37464
37460
}
37465
37461
}
37466
-
37467
- // TODO: look into whether I can synthesize an Identifier for the param
37468
- // Find a reference to try refining; there must be a better way!
37469
- function getIdentifierForParam(param: ParameterDeclaration): Identifier | undefined {
37470
- return func.body && forEachChildRecursively(func.body, (node) => {
37471
- // XXX could I do node.symbol === param.symbol here?
37472
- // resolving identifier "foo" if it's part of "this.foo" will cause an error here.
37473
- if (isIdentifier(node) && !isPropertyAccessExpression(node.parent) && getResolvedSymbol(node) === param.symbol) {
37474
- return node;
37475
- }
37476
- });
37477
- }
37478
37462
}
37479
37463
37480
37464
/**
0 commit comments