Skip to content

[no-delete-optional] Prohibit deleting optional properties #1634

Closed
@Vanuan

Description

@Vanuan

Feature request

{
  "rules": {
    "@typescript-eslint/no-delete-optional": ["error"]
  }
}
type SomeType = { a: string };
const someObject: SomeType = {
  a: string;
}
delete someObject.a;
someObject.a.toString();

Expected Result

Should throw a compile error deleting non-optional property 'a'

Actual Result

Runtime error can't read property 'toString' of undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions