mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Mark implied object destructuring patterns as object literal types
This commit is contained in:
1 parent
bb23e9601f
commit
20c008ecab
1 file changed
+4
-5
@@ -4310,12 +4310,12 @@ namespace ts {
|
||||
function getTypeFromObjectBindingPattern(pattern: ObjectBindingPattern, includePatternInType: boolean, reportErrors: boolean): Type {
|
||||
const members = createSymbolTable();
|
||||
let stringIndexInfo: IndexInfo;
|
||||
let hasComputedProperties = false;
|
||||
let objectFlags = ObjectFlags.ObjectLiteral;
|
||||
forEach(pattern.elements, e => {
|
||||
const name = e.propertyName || <Identifier>e.name;
|
||||
if (isComputedNonLiteralName(name)) {
|
||||
// do not include computed properties in the implied type
|
||||
hasComputedProperties = true;
|
||||
objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties;
|
||||
return;
|
||||
}
|
||||
if (e.dotDotDotToken) {
|
||||
@@ -4331,12 +4331,11 @@ namespace ts {
|
||||
members.set(symbol.escapedName, symbol);
|
||||
});
|
||||
const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined);
|
||||
result.flags |= TypeFlags.ContainsObjectLiteral;
|
||||
result.objectFlags |= objectFlags;
|
||||
if (includePatternInType) {
|
||||
result.pattern = pattern;
|
||||
}
|
||||
if (hasComputedProperties) {
|
||||
result.objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user