assignContextualParameterTypes handles arguments object

Previously, it would crash — the arguments object is a transient
symbol with no declaration, and `getEffectiveTypeAnnotationNode`
does not accept `undefined`.
This commit is contained in:
Nathan Shively-Sanders 2017-09-11 11:16:01 -07:00
parent eb80799ef0
commit 2fdb5b8659

View file

@ -16665,8 +16665,9 @@ namespace ts {
}
}
if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) {
// parameter might be a transient symbol generated by use of `arguments` in the function body.
const parameter = lastOrUndefined(signature.parameters);
if (!getEffectiveTypeAnnotationNode(<ParameterDeclaration>parameter.valueDeclaration)) {
if (isTransientSymbol(parameter) || !getEffectiveTypeAnnotationNode(<ParameterDeclaration>parameter.valueDeclaration)) {
const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType);
}