From fe55edc38e69daaca26efd35bdf40bcb8d173bb4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 29 Nov 2016 13:46:00 -0800 Subject: [PATCH] Rest in an untyped binding pattern should be any --- src/compiler/checker.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 527735a3b0f..65bc52fde1f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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) {