@@ -4298,7 +4298,7 @@ namespace ts {
4298
4298
type = getContextualThisParameterType(func);
4299
4299
}
4300
4300
else {
4301
- type = getContextuallyTypedParameterType(<ParameterDeclaration>declaration)
4301
+ type = getContextuallyTypedParameterType(<ParameterDeclaration>declaration);
4302
4302
}
4303
4303
if (type) {
4304
4304
return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
@@ -4329,8 +4329,8 @@ namespace ts {
4329
4329
4330
4330
// Important to do this *after* attempt has been made to resolve via initializer
4331
4331
if (declaration.kind === SyntaxKind.Parameter) {
4332
- const inferredType = getParameterTypeFromBody(<ParameterDeclaration>declaration)
4333
- if (inferredType) return inferredType
4332
+ const inferredType = getParameterTypeFromBody(<ParameterDeclaration>declaration);
4333
+ if (inferredType) return inferredType;
4334
4334
}
4335
4335
4336
4336
// No type specified and nothing can be inferred
@@ -12805,11 +12805,11 @@ namespace ts {
12805
12805
}
12806
12806
12807
12807
function getParameterTypeFromBody(parameter: ParameterDeclaration): Type {
12808
- const func = <FunctionLikeDeclaration>parameter.parent
12809
- if (!func.body || isRestParameter(parameter)) return
12808
+ const func = <FunctionLikeDeclaration>parameter.parent;
12809
+ if (!func.body || isRestParameter(parameter)) return;
12810
12810
12811
- const types = checkAndAggregateParameterExpressionTypes(parameter)
12812
- return types ? getWidenedType(getIntersectionType(types)) : undefined
12811
+ const types = checkAndAggregateParameterExpressionTypes(parameter);
12812
+ return types ? getWidenedType(getIntersectionType(types)) : undefined;
12813
12813
}
12814
12814
12815
12815
// Return contextual type of parameter or undefined if no contextual type is available
@@ -16744,20 +16744,18 @@ namespace ts {
16744
16744
}
16745
16745
16746
16746
function checkAndAggregateParameterExpressionTypes(parameter: ParameterDeclaration): Type[] {
16747
- const func = <FunctionLikeDeclaration>parameter.parent
16748
- const usageTypes: Type[] = []
16747
+ const func = <FunctionLikeDeclaration>parameter.parent;
16748
+ const usageTypes: Type[] = [];
16749
16749
forEachInvocation(<Block>func.body, invocation => {
16750
16750
const usages = invocation.arguments
16751
16751
.map((arg, i) => ({ arg, symbol: getSymbolAtLocation(arg), i }))
16752
- .filter(({ symbol }) => symbol && symbol.valueDeclaration === parameter)
16753
- if (!usages.length)
16754
- return
16755
- const funcSymbol = getSymbolAtLocation(invocation.expression)
16756
- if (!funcSymbol || !isFunctionLike(funcSymbol.valueDeclaration))
16757
- return
16758
- const sig = getSignatureFromDeclaration(funcSymbol.valueDeclaration)
16759
- const parameterTypes = sig.parameters.map(getTypeOfParameter)
16760
- const argumentTypes = usages.map(({ i }) => parameterTypes[i]).filter(t => !!t)
16752
+ .filter(({ symbol }) => symbol && symbol.valueDeclaration === parameter);
16753
+ if (!usages.length) return;
16754
+ const funcSymbol = getSymbolAtLocation(invocation.expression);
16755
+ if (!funcSymbol || !isFunctionLike(funcSymbol.valueDeclaration)) return;
16756
+ const sig = getSignatureFromDeclaration(funcSymbol.valueDeclaration);
16757
+ const parameterTypes = sig.parameters.map(getTypeOfParameter);
16758
+ const argumentTypes = usages.map(({ i }) => parameterTypes[i]).filter(t => !!t);
16761
16759
usageTypes.splice(0, 0, ...argumentTypes);
16762
16760
});
16763
16761
return usageTypes.length ? usageTypes : undefined;
0 commit comments