delete doesn't count as turning a property to undefined
See original GitHub issuefunction plus1(x) {
return x + 1;
}
let y: { z: number } = {
z: 5
};
delete y.z; // if you switch this line to y.z = undefined it will produce an error
let result = plus1(y.z);
This should return an error because type undefined
is not compatible with type number
Also lovely work so far!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Is it possible to delete a property from an object by setting it to ...
You've set the property value to be undefined but the property still exists. Use delete o.x to remove the property entirely. – evolutionxbox....
Read more >delete operator - JavaScript - MDN Web Docs - Mozilla
The delete operator removes a property from an object. If the property's value is an object and there are no more references to...
Read more >delete obj.property vs obj.property = undefined - this vs that
Calling obj.property = undefined sets the value of property to undefined . The property is still there and appears if we iterate the...
Read more >Data Structures: Objects and Arrays - Eloquent JavaScript
Reading a property that doesn't exist will give you the value undefined . It is possible to assign a value to a property...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sweet! Thank you for the amazing work! ❤️
Unfortunately, there is no kind of list. So, if you will report it in issues, it will be great.