{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/1410","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/1410/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/1410/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/1410/events","html_url":"https://github.com/facebook/flow/issues/1410","id":133843622,"number":1410,"title":"External library is not correctly typechecked","user":{"login":"runn1ng","id":104945,"avatar_url":"https://avatars.githubusercontent.com/u/104945?v=3","gravatar_id":"","url":"https://api.github.com/users/runn1ng","html_url":"https://github.com/runn1ng","followers_url":"https://api.github.com/users/runn1ng/followers","following_url":"https://api.github.com/users/runn1ng/following{/other_user}","gists_url":"https://api.github.com/users/runn1ng/gists{/gist_id}","starred_url":"https://api.github.com/users/runn1ng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runn1ng/subscriptions","organizations_url":"https://api.github.com/users/runn1ng/orgs","repos_url":"https://api.github.com/users/runn1ng/repos","events_url":"https://api.github.com/users/runn1ng/events{/privacy}","received_events_url":"https://api.github.com/users/runn1ng/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/flow/labels/module%20resolution","name":"module resolution","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-15T23:40:42Z","updated_at":"2016-02-19T00:13:17Z","closed_at":null,"body":"We have a problem with typechecking external libraries. It just either doesn't show errors even when it should (so effectively doens't typecheck at all), or shows annoying errors at the top of each file.\r\n\r\nI have made a simple reproduction code here, in this repo.\r\nhttps://github.com/runn1ng/flow_ext_library_example\r\n\r\nI want to use `bitcoinjs-lib` library - [this is my (purposely very short) example interface file](https://github.com/runn1ng/flow_ext_library_example/blob/with_include/types/bitcoin.js):\r\n`````\r\ndeclare module 'bitcoinjs-lib' {\r\n    declare var address: {\r\n        fromBase58Check(address: string): {hash: Buffer, version: number};\r\n    }\r\n}\r\n````\r\n\r\n[This is my code. You can see that both line 3 and 4 should not typecheck - I am using mistakenly Buffer where I should use an object, and I am using `Address` instead of `address` by mistake](https://github.com/runn1ng/flow_ext_library_example/blob/with_include/src/index.js):\r\n`````\r\n/* @flow */\r\nimport * as bitcoin from 'bitcoinjs-lib';\r\nconst foo: Buffer = bitcoin.address.fromBase58Check(\"1CrwjoKxvdbAnPcGzYjpvZ4no4S71neKXT\");\r\nconst bar = bitcoin.Address.fromBase58Check(\"1CrwjoKxvdbAnPcGzYjpvZ4no4S71neKXT\");\r\n```````\r\n\r\n[Now if I add bitcoinjs-lib to the `include` section, like this](https://github.com/runn1ng/flow_ext_library_example/blob/with_include/src/.flowconfig):\r\n`````\r\n[ignore]\r\n\r\n[include]\r\n../node_modules/bitcoinjs-lib\r\n\r\n[libs]\r\n../types/bitcoin.js\r\n\r\n[options]\r\n`````\r\n\r\nflow does not warn me at all about the errors when I run `flow check`. It should! I just added the interface file!\r\n\r\n[If I remove the folder from `include` section, like this](https://github.com/runn1ng/flow_ext_library_example/blob/without_include/src/.flowconfig):\r\n`````\r\n[ignore]\r\n\r\n[include]\r\n\r\n[libs]\r\n../types/bitcoin.js\r\n\r\n[options]\r\n`````\r\n\r\n\r\n`flow check` finally gives me all the errors (which is good), but it also gives me a giant warning:\r\n`````\r\nindex.js:2\r\n2: import * as bitcoin from 'bitcoinjs-lib';\r\n                            ^^^^^^^^^^^^^^^ This modules resolves to \"<<PROJECT_ROOT>>/../node_modules/bitcoinjs-lib/package.json\", which is outside both your root directory and all of the entries in the [includes] section of your .flowconfig. You should either add this directory to the [includes] section of your .flowconfig, move your .flowconfig file higher in the project directory tree, or move this package under your Flow root directory.\r\n`````\r\n...which appears every time I import from 'bitcoinjs-lib'.\r\n\r\nThe repo is set in a way you can just clone it, go to `src` on both branches - `with_include` and `without_include` - and run `flow check`.\r\n\r\nNow what should I do so that the code, using the third-party library, is **actually checked against the interface file**, but that I also don't see the big warnings on `import` everywhere?"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/185988628","html_url":"https://github.com/facebook/flow/issues/1410#issuecomment-185988628","issue_url":"https://api.github.com/repos/facebook/flow/issues/1410","id":185988628,"user":{"login":"runn1ng","id":104945,"avatar_url":"https://avatars.githubusercontent.com/u/104945?v=3","gravatar_id":"","url":"https://api.github.com/users/runn1ng","html_url":"https://github.com/runn1ng","followers_url":"https://api.github.com/users/runn1ng/followers","following_url":"https://api.github.com/users/runn1ng/following{/other_user}","gists_url":"https://api.github.com/users/runn1ng/gists{/gist_id}","starred_url":"https://api.github.com/users/runn1ng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runn1ng/subscriptions","organizations_url":"https://api.github.com/users/runn1ng/orgs","repos_url":"https://api.github.com/users/runn1ng/repos","events_url":"https://api.github.com/users/runn1ng/events{/privacy}","received_events_url":"https://api.github.com/users/runn1ng/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T00:13:17Z","updated_at":"2016-02-19T00:13:17Z","body":"Yep, you are right! Should I close this?"}}