-
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
Document .js.flow files #3609
Comments
Yes, this is still supported. |
Can you comment on this? |
I've tried really hard to get a simple example of this to work and can't get it to detect a simple error where I pass a string for parameter that must be a number. Are you sure math.js function double(n) {
return n * 2;
}
exports.double = double; math.js.flow //function double(n: number): number {} // doesn't work
declare export function double(n: number): number; // doesn't work demo.js // @flow
const math = require('./math');
console.log(math.double('bad')); // Flow should flag this, but doesn't When I run |
I'm also not observing any enforcement by .js.flow files. Same sort of situation as @mvolkmann. Any help would be appreciated. |
Very much would like this documented as well. Could inhibit adoption if we don't document this as it's one way to convince a team to transition to Flow without touching the JavaScript source. |
Having the same issue after using EDIT: The above example works if |
Using Flow 0.59.0, I can't figure out how to use index.js.flowdeclare export class Foo<T> {
bar(value: T): T;
} index.jsclass Foo {
bar(value) {
return value
}
}
module.exports = Foo I've also tried adding |
What I ended up doing was taking a Facebook open source project Draft JS (which auto-generates their .js.flow files) to figure out how they are formatted. If you clone and build the project and look in the "lib" directory, you'll see that the .js.flow files are just the raw js files with the flow syntax in them. I think flow just sees a .flow extension for a file corresponding to the one you add and it just type checks against that. |
@mvolkmann I believe math.js still needs the |
Assuming that's the error, I normally use this linter rule to catch misses like that. |
What's the status of this as of today (0.69) ? |
You the issue is most vendors don't ship their |
@dperetti Sorry, what? Everything works fine with |
Doh! Found a culprit in my |
The old documentation described how you could omit types in a file called
foo.js
and declare the types in a file calledfoo.js.flow
that is located in the same directory. I can't find that in the new documentation. Is that still a supported way to specify types?The text was updated successfully, but these errors were encountered: