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
functionpartialToFull<T>(x: Partial<T>): T{returnxasT;}interfaceFoo{bar?: string;};constfoo: Foo={bar: 'baz'};constfull=partialToFull(foo);deletefull.bar;// error TS2790: The operand of a 'delete' operator must be optional.
Expected behavior:
It should work, as the property is optional.
Actual behavior:
It fails.
If I explicitly assign the type to full, it works:
I'm not sure why this is the "expected" behavior -- the entire point of the partialToFull type signature is to erase optionality; that's what it's written to do.
TypeScript Version: 4.1.0-dev.20200824
Search Terms: Partial optional
Code
Expected behavior:
It should work, as the property is optional.
Actual behavior:
It fails.
If I explicitly assign the type to full, it works:
Playground Link: Link
Related Issues: #13783
The text was updated successfully, but these errors were encountered: