Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler should warn when deleting a property that can't be undefined #2734

Open
shicks opened this issue Nov 30, 2017 · 0 comments
Open

Compiler should warn when deleting a property that can't be undefined #2734

shicks opened this issue Nov 30, 2017 · 0 comments

Comments

@shicks
Copy link
Member

shicks commented Nov 30, 2017

repro

The compiler already warns when you try to set such a property to undefined, but deleteing it circumvents this warning:

const /** {x: number, y: number} */ point = {x: 1, y:2};

point.x = null;       // Compiler does warn
point.x = undefined;  // Compiler does warn
delete point.x;       // Compiler does not warn
input0:3: WARNING - assignment to property x of point
found   : null
required: number
point.x = null;  // Compiler does warn
^^^^^^^^^^^^^^

input0:4: WARNING - assignment to property x of point
found   : undefined
required: number
point.x = undefined;  // Compiler does warn
^^^^^^^^^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant