Skip to content

Commit a6a34c1

Browse files
committed
param.name!
1 parent 07eef2a commit a6a34c1

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37435,11 +37435,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3743537435
antecedent,
3743637436
};
3743737437

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);
3744337439
if (narrowedParamTypeTrue === initType) {
3744437440
continue;
3744537441
}
@@ -37451,7 +37447,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3745137447
...trueCondition,
3745237448
flags: FlowFlags.FalseCondition | FlowFlags.Referenced | FlowFlags.Shared,
3745337449
}
37454-
const narrowedParamTypeFalse = getFlowTypeOfReference(paramId, initType, initType, func, falseCondition);
37450+
const narrowedParamTypeFalse = getFlowTypeOfReference(param.name, initType, initType, func, falseCondition);
3745537451
// It's safe to infer a type guard if:
3745637452
// narrowedParamTypeFalse = Exclude<initType, narrowedParamTypeTrue>
3745737453
// what's the difference between a subtype and assignable relationship?
@@ -37463,18 +37459,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3746337459
}
3746437460
}
3746537461
}
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-
}
3747837462
}
3747937463

3748037464
/**

0 commit comments

Comments
 (0)