{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/181","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/181/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/181/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/181/events","html_url":"https://github.com/facebook/flow/issues/181","id":51411794,"number":181,"title":"Problem with module name 'moment'","user":{"login":"skogsbaer","id":567524,"avatar_url":"https://avatars.githubusercontent.com/u/567524?v=3","gravatar_id":"","url":"https://api.github.com/users/skogsbaer","html_url":"https://github.com/skogsbaer","followers_url":"https://api.github.com/users/skogsbaer/followers","following_url":"https://api.github.com/users/skogsbaer/following{/other_user}","gists_url":"https://api.github.com/users/skogsbaer/gists{/gist_id}","starred_url":"https://api.github.com/users/skogsbaer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skogsbaer/subscriptions","organizations_url":"https://api.github.com/users/skogsbaer/orgs","repos_url":"https://api.github.com/users/skogsbaer/repos","events_url":"https://api.github.com/users/skogsbaer/events{/privacy}","received_events_url":"https://api.github.com/users/skogsbaer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/flow/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2014-12-09T10:35:27Z","updated_at":"2016-09-16T18:52:11Z","closed_at":null,"body":"I try to use the momentjs library with flow. I got a .d.ts file from https://github.com/borisyankov/DefinitelyTyped/blob/master/moment/moment.d.ts but couldn't convince flow to accept the moment module.\r\n\r\nI debugged the problem and discovered that the module name 'moment' causes the problem.\r\n\r\nI have created a strip-down version of the problem.\r\n\r\n```\r\n$ tree -a\r\n.\r\n├── .flowconfig\r\n├── jssrc\r\n│   └── Sample.js\r\n└── lib\r\n    └── moment.d.ts\r\n```\r\n\r\n```\r\n$ cat .flowconfig\r\n[ignore]\r\n\r\n[include]\r\n./jssrc/\r\n\r\n[libs]\r\n./lib/moment.d.ts\r\n\r\n[options]\r\n```\r\n\r\n```\r\n$ cat jssrc/Sample.js\r\n/* @flow */\r\n\r\nvar moment = require('moment'); // REPLACE 'moment' with 'foobar' to get it working\r\n```\r\n\r\n```\r\n$ cat lib/moment.d.ts\r\ndeclare module moment { // replace moment with foobar to get it working\r\n}\r\n```\r\n\r\nIf I now run `flow`, I get\r\n\r\n```\r\n$ flow check\r\n\r\njssrc/Sample.js:3:14,30: moment.js\r\nRequired module not found\r\n```\r\n\r\nIf I replace the two occurrences of moment with foobar, I get\r\n\r\n```\r\n$ flow check\r\n\r\nFound 0 errors\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/247678823","html_url":"https://github.com/facebook/flow/issues/181#issuecomment-247678823","issue_url":"https://api.github.com/repos/facebook/flow/issues/181","id":247678823,"user":{"login":"mroch","id":3012,"avatar_url":"https://avatars.githubusercontent.com/u/3012?v=3","gravatar_id":"","url":"https://api.github.com/users/mroch","html_url":"https://github.com/mroch","followers_url":"https://api.github.com/users/mroch/followers","following_url":"https://api.github.com/users/mroch/following{/other_user}","gists_url":"https://api.github.com/users/mroch/gists{/gist_id}","starred_url":"https://api.github.com/users/mroch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mroch/subscriptions","organizations_url":"https://api.github.com/users/mroch/orgs","repos_url":"https://api.github.com/users/mroch/repos","events_url":"https://api.github.com/users/mroch/events{/privacy}","received_events_url":"https://api.github.com/users/mroch/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T18:52:11Z","updated_at":"2016-09-16T18:52:11Z","body":"This repros:\r\n\r\n```\r\nmkdir -p test\r\npushd test\r\nprintf \"declare module foobar {\\n  declare var foo: string;\\n}\\n\" > lib.d.ts\r\nprintf \"[libs]\\nlib.d.ts\\n\" > .flowconfig\r\nprintf \"// @flow\\n\\n((require('foobar').foo): number);\\n\" > index.js\r\nflow check\r\n# got a missing module error, rather than complaining that foo is a string, not a number\r\npopd\r\n```\r\n\r\nThe problem is that Flow only looks at file extensions `.js` and `.json`, not `.ts`, even if the entry in `[libs]` is an actual file."}}
{"actor":{"display_login":"mroch"}}