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
constsomeObject={foo: 'bar',baz: true}deletesomeObject.foo// The operand of a 'delete' operator must be optional.(2790)
π Actual behavior
You cannot delete from a literal object without facing the error.
You are forced to type the object, marking the property you want to delete as optional, even though it is not optional up until that point.
π Expected behavior
Since you never provided a type to the object, you should be able to delete from it, and afterwards it gets marked as optional.
Alternatively, the check should be divorced from strictNullChecks so it can be turned off separately
The text was updated successfully, but these errors were encountered:
@RyanCavanaugh fwiw 13783 involves explicit type annotations - the OP here has an inferred object literal and seems to be expecting it to act as an evolving type.
Maybe worth noting that thereβs no way to declare a property as optional in an object literal without a type annotationβ¦
Bug Report
π Search Terms
Cannot
delete
from inferred types without typing them firstπ Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
You cannot delete from a literal object without facing the error.
You are forced to type the object, marking the property you want to delete as optional, even though it is not optional up until that point.
π Expected behavior
Since you never provided a type to the object, you should be able to delete from it, and afterwards it gets marked as optional.
Alternatively, the check should be divorced from
strictNullChecks
so it can be turned off separatelyThe text was updated successfully, but these errors were encountered: