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

Readonly<T> not working #28968

Closed
trusktr opened this issue Dec 11, 2018 · 3 comments
Closed

Readonly<T> not working #28968

trusktr opened this issue Dec 11, 2018 · 3 comments
Assignees
Labels
Fixed A PR has been merged for this issue Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript

Comments

@trusktr
Copy link
Contributor

trusktr commented Dec 11, 2018

TypeScript Version: 3.3.0-dev.20181208

Search Terms:

Readonly

Code

const a: Readonly<number[]> = [1,2,3]
a[1] = 4

Expected behavior:

Should not let me write.

Actual behavior:

It does.

Playground Link:

http://www.typescriptlang.org/play/#src=const%20a%3A%20Readonly%3Cnumber%5B%5D%3E%20%3D%20%5B1%2C2%2C3%5D%0Aa%5B1%5D%20%3D%204%0A

Related Issues:

@weswigham weswigham added Suggestion An idea for TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Dec 11, 2018
@trusktr
Copy link
Contributor Author

trusktr commented Dec 12, 2018

@weswigham based on your labels, I suppose this is something that never worked the way I was expecting above?

@trusktr
Copy link
Contributor Author

trusktr commented Dec 12, 2018

Ah, I didn't know about ReadonlyArray, that works well:

const a: ReadonlyArray<number[]> = [1,2,3]
a[1] = 4

(playground)

@AlCalzone
Copy link
Contributor

It should be ReadonlyArray<number> btw :)

@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed A PR has been merged for this issue Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants