-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Arbitrary properties of function object have type any #106
Comments
Known issue, will fix. (A function has an underlying object that stores its static properties; in general we keep objects created inside a module extensible, so we don't immediately error out on property accesses because they may be defined in other parts of the file the type checker hasn't yet visited. But we should be stricter in cases like the one you point out.) |
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed. |
Would be curious to hear if there's an update on this. |
Any news on this ? |
@avikchaudhuri Do you think defaulting to |
Properties on function types are currently unsound in flow: facebook/flow#106
Properties on function types are currently unsound in flow: facebook/flow#106
Properties on function types are currently unsound in flow: facebook/flow#106
Just re-activating this thread, by pointing out that this weakness in Flow's type system does lead to real-world bugs, particularly around the use of promises. For instance: function getPromise(): Promise<boolean> {
return Promise.resolve(true)
}
// type-checks, works at runtime
getPromise().then(() => true);
// type-checks, fails at runtime
getPromise.then(() => true); I understand that functions are ultimately objects in JavaScript, but so are arrays, and they have stricter type-checking in Flow. Why not functions too? // type-checks, fails at runtime
({}).blah(() => 'hey')
// type-checks, fails at runtime
(() => {}).blah(() => 'hey')
// doesn't type-check, fails at runtime
[].blah(() => 'hey') Any insights you can give into the decisions around this would be much appreciated! |
@avikchaudhuri I see you mentioned 5 years ago that this will be fixed. Just pinging to see if there's any progress :D |
Fixed 0.187 |
Search keywords: function, statics
Flow finds no error in the following code:
I think it is a bug because both noop.foo and noop.bar are undefined.
The text was updated successfully, but these errors were encountered: