You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
access_property of ((BarProps#1 & object) | {}) is expected to fail, because {} does not have the property.
But the type of fooProps should be (BarProps#1 & object) (without union)
Is the object part relevant here? Looks like tsc infersBarProps even when fooProps has type BarProps, without the object intersection.
I would guess we should infer BarProps | DefaultValue if DefaultValue is not assignable to BarProps & object, and just BarProps otherwise. {} is assignable to BarProps & object (or BarProps fwiw), so we should infer BarProps & object
kdy1
changed the title
Default value of an object pattern property should not change type
Default value of an object pattern property should not change type if it's assignable
Nov 6, 2022
stc/crates/stc_ts_type_checker/tests/conformance/types/nonPrimitive/nonPrimitiveAndEmptyObject.ts
Lines 6 to 17 in d121f20
This should success.
access_property
of((BarProps#1 & object) | {})
is expected to fail, because{}
does not have the property.But the type of
fooProps
should be(BarProps#1 & object)
(without union)I think the logic at
stc/crates/stc_ts_file_analyzer/src/analyzer/scope/vars.rs
Lines 483 to 500 in d121f20
The text was updated successfully, but these errors were encountered: