Skip to content

Commit 42d61b5

Browse files
author
Kanchalai Tanglertsampan
committed
Call checkExpression eventhough there is no appropriate type from destructuring of array
1 parent acfdfe0 commit 42d61b5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4447,9 +4447,14 @@ namespace ts {
44474447
return property;
44484448
}
44494449

4450-
// Return the symbol for the property with the given name in the given type. Creates synthetic union properties when
4451-
// necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from
4452-
// Object and Function as appropriate.
4450+
/**
4451+
* Return the symbol for the property with the given name in the given type. Creates synthetic union properties when
4452+
* necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from
4453+
* Object and Function as appropriate.
4454+
*
4455+
* @param type a type to look up property from
4456+
* @param name a name of property to look up in a given type
4457+
*/
44534458
function getPropertyOfType(type: Type, name: string): Symbol {
44544459
type = getApparentType(type);
44554460
if (type.flags & TypeFlags.ObjectType) {
@@ -12856,6 +12861,9 @@ namespace ts {
1285612861
return checkDestructuringAssignment(element, type, contextualMapper);
1285712862
}
1285812863
else {
12864+
// We still need to check element expression here because we may need to set appropriate flag on the expression
12865+
// such as NodeCheckFlags.LexicalThis on "this"expression.
12866+
checkExpression(element);
1285912867
if (isTupleType(sourceType)) {
1286012868
error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), (<TupleType>sourceType).elementTypes.length, elements.length);
1286112869
}

0 commit comments

Comments
 (0)