-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
TS2495: Type 'Readonly<any[]>' is not an array type or a string type #12377
Comments
This is because /**
* Prevents the modification of existing property attributes and values,
* and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze<T, V>(o: T & { [Symbol.iterator]: V }): Readonly<T> & { [Symbol.iterator]: V };
freeze<T>(o: T): Readonly<T>; |
we should add an overload to freeze for arrays: freeze<T>(o: T[]): ReadonlyArray<T>;
freeze<T>(o: T): Readonly<T>; |
@mhegazy would you be open to a PR? |
PRs welcomed |
also we need to handle functions differently. let handler = Object.freeze(function(callback, context?) { return 0; });
handler(); // Error now, no call signature |
Yeah there are a bunch of tricky scenarios. Also something that came to mind when special casing |
TypeScript Version: master
Code
Expected behavior:
pass
Actual behavior:
The text was updated successfully, but these errors were encountered: