mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Add missing optional properties only when not inferentially typing
This commit is contained in:
parent
21e6784038
commit
f661508bb6
@ -5455,9 +5455,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
// If object literal is contextually typed, add missing optional properties from the contextual type
|
||||
// such that the resulting type becomes a subtype in cases where only optional properties were omitted
|
||||
if (contextualType) {
|
||||
// If object literal is contextually (but not inferentially) typed, copy missing optional properties from
|
||||
// the contextual type such that the resulting type becomes a subtype in cases where only optional properties
|
||||
// were omitted. There is no need to create new property objects as nothing in them needs to change.
|
||||
if (contextualType && !isInferentialContext(contextualMapper)) {
|
||||
forEach(getPropertiesOfObjectType(contextualType), p => {
|
||||
if (p.flags & SymbolFlags.Optional && !hasProperty(properties, p.name)) {
|
||||
properties[p.name] = p;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user