{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/4280","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/4280/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/4280/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/4280/events","html_url":"https://github.com/facebook/flow/issues/4280","id":239615674,"number":4280,"title":"Modules connected by webpack.ProvidePlugin are typed 'any'","user":{"login":"showmeyourhits","id":17144356,"avatar_url":"https://avatars2.githubusercontent.com/u/17144356?v=4","gravatar_id":"","url":"https://api.github.com/users/showmeyourhits","html_url":"https://github.com/showmeyourhits","followers_url":"https://api.github.com/users/showmeyourhits/followers","following_url":"https://api.github.com/users/showmeyourhits/following{/other_user}","gists_url":"https://api.github.com/users/showmeyourhits/gists{/gist_id}","starred_url":"https://api.github.com/users/showmeyourhits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/showmeyourhits/subscriptions","organizations_url":"https://api.github.com/users/showmeyourhits/orgs","repos_url":"https://api.github.com/users/showmeyourhits/repos","events_url":"https://api.github.com/users/showmeyourhits/events{/privacy}","received_events_url":"https://api.github.com/users/showmeyourhits/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-06-29T21:25:26Z","updated_at":"2018-05-17T11:38:34Z","closed_at":null,"author_association":"NONE","body":"Howdy. I'm sorry if this issue already exists. This more question than issue report.\r\nMy project frequently uses `moment`, `underscore`, `React` etc, so my team decided to carry out this modules in `webpack` config to **`ProvidePlugin`,** that makes them global variables.\r\n\r\n\r\n**webpack.config.js:** ` {...,\r\nplugins: [\r\n\t\tnew webpack.ProvidePlugin({\r\n\t\t\t'React': 'react',\r\n\t\t\t'_': 'underscore',\r\n\t\t}),\r\n\t], ...}\r\n`\r\n\r\nNow, when i tried to connect `flow`, it of course could not resolve their names.\r\nAfter reading documentation, i tried to create `flow-typed/customLibDef.js` like that\r\n```\r\nimport underscore from 'underscore';\r\n\r\ndeclare var _: typeof underscore;\r\ndeclare var moment: Class<moment$Moment>;\r\n```\r\n\r\nAnd it works for moment, but not for _: it typed as 'any'.\r\nSame goes for React and PropTypes modules: connecting them by plugin and not importing them explicitly in my code will throw a flow error.\r\nSo i ask: is there any way to let flow know about this globals without importing them everywhere they are needed? A way to declare modules globally?"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/389836957","html_url":"https://github.com/facebook/flow/issues/4280#issuecomment-389836957","issue_url":"https://api.github.com/repos/facebook/flow/issues/4280","id":389836957,"user":{"login":"neutraali","id":16540190,"avatar_url":"https://avatars0.githubusercontent.com/u/16540190?v=4","gravatar_id":"","url":"https://api.github.com/users/neutraali","html_url":"https://github.com/neutraali","followers_url":"https://api.github.com/users/neutraali/followers","following_url":"https://api.github.com/users/neutraali/following{/other_user}","gists_url":"https://api.github.com/users/neutraali/gists{/gist_id}","starred_url":"https://api.github.com/users/neutraali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neutraali/subscriptions","organizations_url":"https://api.github.com/users/neutraali/orgs","repos_url":"https://api.github.com/users/neutraali/repos","events_url":"https://api.github.com/users/neutraali/events{/privacy}","received_events_url":"https://api.github.com/users/neutraali/received_events","type":"User","site_admin":false},"created_at":"2018-05-17T11:38:34Z","updated_at":"2018-05-17T11:38:34Z","author_association":"NONE","body":"Right, so I looked it up and made a \"global definition file\" at `lib/Flow.js`. I then added this path to `.flowconfig` under `[libs]`. Seems to be working perfectly! Thanks to @apsavin for the pointers.\r\n\r\nThe next thing I'll have to worry about are Webpack _alias paths_, e.g. `custom-path/lib/Example.js`, but having those global module definitions is a huge enough deal already. :smile_cat: "}}
{"actor":{"display_login":"neutraali"}}