Maybe this has been asked already or it's not working for me, but I keep getting these errors:
/client/components/App.js:12:19,24: identifier Meteor
Unknown global name
How can i make Meteor global?
I have done flow start --lib ./lib which contains a file meteor.js that has declare var Meteor: any but it doesn't seem to work.
So if i add declare var Meteor: any; to the files that contain the globals, the error goes away, is there anyway to do this globally for all files?
It seems to me that the solution is not to rely on globals but to use modules instead? Unless Meteor is being imported via a module loader?
@briandipalma Well Meteor doesn't quite work that way (the environment provides a Meteor object on the client/server), but flow needs to have a way to define globals for it, while they may not be best practice it's something that a lot of applications are going to have.
@josebalius Could you try again putting lib outside .? Maybe putting it in the same directory as source files is making Flow clobber the information that it is a global? :/ Will investigate, also let us know if the workaround doesn't work.
@avikchaudhuri I tried putting it in the same folder as the other files (that reference the global), created a file called globals.js with the following:
/* @flow */
declare var Meteor: any;
But still got the same error, the other thing i was thinking, should I set the --lib property with an absolute path like we have to do .flowconfig for ignore / include ? I haven't tried that, I will now just in case.
No, what I mean is, put globals.js somewhere _outside_ the folder which contains your regular files.
@avikchaudhuri okay just tried that as well and no luck :(
@josebalius I ran into the same problem, then saw in the documentation that you need to specify the --lib argument even when running the check command. For example:
flow start --lib ../lib
flow check --lib ../lib
@Eric-Wright thank you! that definitely fixed it :)
I think we can close this issue now, but it should be documented that you have to keep specifying the --lib argument when running flow check
It would be nice if flow allowed you to run flow --lib ./lib without having to do a full flow check it's so slow....
@josebalius if you run flow start --lib ./lib and then run flow it will use the lib.
@tcoopman you sure? if I run it like that, i get the global errors, it does not have the same result as flow check --lib ./lib
@josebalius just tested it with 0.1.1 and this works.
Are you sure the lib file get parsed correctly?
@tcoopman It worked for you :( you don't get global errors? I think it is, i mean it works with flow check and i thought lib was supposed to be a folder?
Yeah it has to be a folder. So you first run flow start --lib lib/ and
then flow?
Maybe try again on a test directory to see that there is nothing wrong with
something else?
On Fri, 21 Nov 2014 21:59 Jose Garcia [email protected] wrote:
@tcoopman https://github.com/tcoopman It worked for you :( you don't
get global errors? I think it is, i mean it works with flow check and i
thought lib was supposed to be a folder?—
Reply to this email directly or view it on GitHub
https://github.com/facebook/flow/issues/45#issuecomment-64036742.
@tcoopman just verified it. Also verified I had version 0.1.1 just to double check and i do. Here is what i did:
File structure:
drwxr-xr-x 3 jgarcia staff 102 Nov 22 20:08 lib
-rw-r--r-- 1 jgarcia staff 30 Nov 22 20:08 test.js
test.js
TestGlobal.run();
lib
-rw-r--r-- 1 jgarcia staff 29 Nov 22 20:08 global.js
global.js
declare var TestGlobal: any;
Test:
flow init
------------
flow start --lib ./lib
flow
/Users/jgarcia/Sites/flow-test/test.js:2:1,10: identifier TestGlobal
Unknown global name
Found 1 error
---------
flow start lib ./lib
flow check --lib ./lib
Found 0 errors
Let me know if you can reproduce.
I've taken your exact example and cannot reproduce:
flow init
flow start --lib ./lib
flow
No errors!
(Running it like without --lib does give an error)
I'm on Linux, maybe that could be the problem?
Also can you test this:
flow start --lib ./lib
flow status
What's the full output of flow status?
@tcoopman
~/Sites/flow-test
â–¶ flow start --lib ./lib
Spawned flow server (child pid=22957)
Logs will go to /var/folders/9k/tr3kf4zn70d5cbp8kzzdzjqw0000gp/T/flow_jgarcia/jgarcia-zSUserszSjgarciazSSiteszSflow-test.log
~/Sites/flow-test
â–¶ flow status
/Users/jgarcia/Sites/flow-test/test.js:2:1,10: identifier TestGlobal
Unknown global name
Found 1 error
I thought that maybe the server stopped, I've had this happen once, but it looks like it is still running.
Maybe someone else on a Mac can check if they have the same problem?
Anyone else? :/
Mayb
On Nov 25, 2014 9:46 AM, "Jose Garcia" [email protected] wrote:
Anyone else? :/
—
Reply to this email directly or view it on GitHub
https://github.com/facebook/flow/issues/45#issuecomment-64419620.
@pizana68 are you having the same problem?
@avikchaudhuri @tcoopman so I tried setting the --lib option in flow start with an absolute path instead of relative, and it works!
@josebalius can this issue be closed?
@tcoopman yes sir :)
Most helpful comment
So if i add
declare var Meteor: any;to the files that contain the globals, the error goes away, is there anyway to do this globally for all files?