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

Prevent delete non-optional property #29538

Closed
5 tasks done
s97712 opened this issue Jan 23, 2019 · 1 comment
Closed
5 tasks done

Prevent delete non-optional property #29538

s97712 opened this issue Jan 23, 2019 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@s97712
Copy link

s97712 commented Jan 23, 2019

Search Terms

Suggestion

Prevent delete non-optional property

Use Cases

Examples

inferface Test{
  value: number
}

const foo: Test = {
  value:1
}

foo.value = undefined
[ts] Type 'undefined' is not assignable to type 'number'. [2322]
the compiler reported error, everything is normal

delete foo.value;
The complier should be prevent this situation, it behaviors like the foo.value = undefined, but here complier reported not error.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@ajafff
Copy link
Contributor

ajafff commented Jan 23, 2019

Related to #26549 and probably a duplicate of #13783

There's a lint rule to disallow delete on non-optional properties: https://github.com/fimbullinter/wotan/blob/master/packages/mimir/docs/delete-only-optional-property.md (CLI documentation)

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants