-
Notifications
You must be signed in to change notification settings - Fork 57
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
Initial support for $ReadOnlyArray #236
base: master
Are you sure you want to change the base?
Conversation
return compareTypes(elementType, input.elementType); | ||
} | ||
else { | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add subtyping here too
I skimmed the code...just realized, there's probably not a clean way to throw a runtime error if a |
On second thought though, could statements like |
@jedwards1211 what about casting to any? It should basically unfreeze array which is impossible to do, that's why I'm having concern with it |
Ok, I see that |
Oh, it can trace assignments with Babel? var foo: string;
foo = 1; was converted to import t from "flow-runtime";
var _fooType = t.string(),
foo;
foo = _fooType.assert(1); |
Right you can look up where an identifier was declared using |
@jedwards1211 can I check what type annotation it has? This would work for |
@gajus what would you think about just using the same runtime type as |
Sounds acceptable. |
@goodmind I was thinking about this again because I use a lot of readonly types nowadays. It wouldn't actually make sense to insert any runtime checks for modifications on readonly-typed expressions, because such code paths would always throw (it's never in the developer's interest to write such a code path). For that reason it's really better to just rely on Flow to catch such cases, and not do anything special with the read-only status in |
Any-casting seems problematic with
Object.freeze
IssueHunt Summary
Referenced issues
This pull request has been submitted to:
IssueHunt has been backed by the following sponsors. Become a sponsor