Rest in an untyped binding pattern should be any

This commit is contained in:
Nathan Shively-Sanders
2016-11-29 13:46:00 -08:00
parent e313fef683
commit fe55edc38e

View File

@@ -3099,6 +3099,15 @@ namespace ts {
error(declaration, Diagnostics.Rest_types_may_only_be_created_from_object_types);
return unknownType;
}
const parent = pattern.parent as VariableLikeDeclaration;
if (parent.kind === SyntaxKind.Parameter &&
!parent.type &&
!parent.initializer &&
!getContextuallyTypedParameterType(parent as ParameterDeclaration)) {
// if this type came from examining the structure of the pattern --
// there was no other information -- then it is not sufficient to determine the rest type, so just return any
return anyType;
}
const literalMembers: PropertyName[] = [];
for (const element of pattern.elements) {
if (!(element as BindingElement).dotDotDotToken) {