-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Readonly<Float32Array> not assignable to Float32Array #31253
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
Comments
This is caused by the fact that symbols aren’t preserved by mapped types. |
Yep, or more specifically, they’re not exposed by |
Mapped types do retain symbol keys - Certain builtin symbols (ie, |
Glad to see this is being fixed, just found out that this does not currently work: const asyncIterable: AsyncIterable<number> = Object.freeze({
* [Symbol.asyncIterator]() {
yield 1
yield 2
},
}) |
@DanielRosenwasser @RyanCavanaugh this is in the 3.6.1 milestone, but I don’t think it’s actionable without #24738, which, uh, probably cannot go into 3.6. |
edit this part is a bug my mistake ... |
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
Expected behavior:
No error.
Though I would expect not to be able to pass a Readonly value to a function which can mutate it but that's another issue.
Actual behavior:
Error on line 2:
Playground Link:
See in playground
Note I can workaround the issue by using mappable types on the function arguments but this is pretty verbose and not something I will want to litter a codebase with - Also not going to work with third-party libraries. See that here. Edit: Actually seen another way to do it which is much less verbose here. This however loops again back to this issue since it really should be raising an error (if in strict mode).
Related Issues:
N/A
The text was updated successfully, but these errors were encountered: