Flow is warning me about a variable that it cannot resolve:
identifier
__VERSION__
Could not resolve name
module.exports = {
__VERSION__,
-----------
...
}
__VERSION__
is a "free variable" injected by webpack's DefinePlugin
:
http://webpack.github.io/docs/list-of-plugins.html#defineplugin
new webpack.DefinePlugin({
__VERSION__: 'v1.0.0',
})
Is there a way to let Flow know about this variable? Is there a way to tie Flow's config with webpack's config so that it knows about these free variables?
Using flow declarations, you can just define them:
declare var __VERSION__:string;
Then flow will typecheck correctly
thank you!
Thanks, @leonardfactory!
Thanks @leonardfactory!
For anybody else who finds this via Google:
You can declare global variables without breaking any other tool that parses your file by using Flow's comment type syntax.
For example we can define the global chrome
without breaking Firefox's linting rule requirements for submitting extensions to the Mozilla addons page.
/*::
declare var chrome;
*/
Most helpful comment
Using flow declarations, you can just define them:
Then flow will typecheck correctly