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

Deletion of readonly property is allowed #14034

Closed
hamishdh opened this issue Feb 13, 2017 · 1 comment
Closed

Deletion of readonly property is allowed #14034

hamishdh opened this issue Feb 13, 2017 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@hamishdh
Copy link

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

Code

interface Foo {
    readonly Property: string;
}

let bar: Foo = {
    Property: "Baz!"
};

bar.Property = undefined; // Disallowed - Cannot Assign to 'Property' because it is a constant or a read-only property
delete bar.Property; // Allowed

Expected behavior:

The TS compiler should disallow deletion of a read-only property.

Actual behavior:

The TS compiler allows deletion of a read-only property.

@RyanCavanaugh
Copy link
Member

See #11480. Please search before logging new issues and please fill in a correct version number in the template. This is now an error.

error TS2704: The operand of a delete operator cannot be a read-only property

image

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Feb 13, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants