@@ -2416,12 +2416,12 @@ namespace ts {
24162416 // Return the type implied by a binding pattern element. This is the type of the initializer of the element if
24172417 // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
24182418 // pattern. Otherwise, it is the type any.
2419- function getTypeFromBindingElement(element: BindingElement): Type {
2419+ function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean ): Type {
24202420 if (element.initializer) {
24212421 return getWidenedType(checkExpressionCached(element.initializer));
24222422 }
24232423 if (isBindingPattern(element.name)) {
2424- return getTypeFromBindingPattern(<BindingPattern>element.name, /* includePatternInType*/ false );
2424+ return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType);
24252425 }
24262426 return anyType;
24272427 }
@@ -2433,7 +2433,7 @@ namespace ts {
24332433 let flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0);
24342434 let name = e.propertyName || <Identifier>e.name;
24352435 let symbol = <TransientSymbol>createSymbol(flags, name.text);
2436- symbol.type = getTypeFromBindingElement(e);
2436+ symbol.type = getTypeFromBindingElement(e, includePatternInType );
24372437 members[symbol.name] = symbol;
24382438 });
24392439 let result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
@@ -2450,7 +2450,7 @@ namespace ts {
24502450 return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType;
24512451 }
24522452 // If the pattern has at least one element, and no rest element, then it should imply a tuple type.
2453- let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e));
2453+ let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType ));
24542454 let result = createTupleType(elementTypes);
24552455 if (includePatternInType) {
24562456 result = clone(result);
0 commit comments