{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4595","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4595/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4595/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4595/events","html_url":"https://github.com/Microsoft/TypeScript/issues/4595","id":104340155,"number":4595,"title":"Module imports need to recognize/ignore the file extension","user":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars.githubusercontent.com/u/2932786?v=3","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-01T19:47:38Z","updated_at":"2015-09-02T13:24:00Z","closed_at":null,"body":"Currently, TS can't find modules when you use a file extension in the import name (`import {Foo} from './foo.ts';`) - [SystemJS updated](https://github.com/systemjs/systemjs/releases/tag/0.17.0) and file extensions are now [_required_](https://github.com/whatwg/loader/issues/52) (though the spec issue is still under discussion) on imports (without setting some legacy settings in `System.config`). So when compiling with `--module`, you can either have a functioning typechecker (no extensions on your imports) or a functioning runtime (`.js` on your imports, since your result files have `.js` extensions). This is complicated further by systemjs's [bundler](https://github.com/systemjs/builder), which looks for dependent files _before_ TS transpiles them, so you have to use `.ts` extensions on your imports so the _bundler_ can resolve the paths to real ones.\r\n\r\nThis extension madness is all incredibly awkward to work with, and I'm not sure if this needs module resolution logic updating on our part, arguing for old behavior on the loader spec, or talking to `systemjs` and having them change how they're finding modules ignoring the spec."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/137077305","html_url":"https://github.com/Microsoft/TypeScript/issues/4595#issuecomment-137077305","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4595","id":137077305,"user":{"login":"kitsonk","id":1282577,"avatar_url":"https://avatars.githubusercontent.com/u/1282577?v=3","gravatar_id":"","url":"https://api.github.com/users/kitsonk","html_url":"https://github.com/kitsonk","followers_url":"https://api.github.com/users/kitsonk/followers","following_url":"https://api.github.com/users/kitsonk/following{/other_user}","gists_url":"https://api.github.com/users/kitsonk/gists{/gist_id}","starred_url":"https://api.github.com/users/kitsonk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kitsonk/subscriptions","organizations_url":"https://api.github.com/users/kitsonk/orgs","repos_url":"https://api.github.com/users/kitsonk/repos","events_url":"https://api.github.com/users/kitsonk/events{/privacy}","received_events_url":"https://api.github.com/users/kitsonk/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T13:24:00Z","updated_at":"2015-09-02T13:24:00Z","body":"I hate to say this (and having read through the thread you linked to) that is madness.  Are TC39 going to seriously consider adopting that?  My initial reaction is now is the time to abandon SystemJS before it gets too late.  I think @jrburke tried (sadly fruitlessly) to explain why that approach is going to cause all sorts of problems.  Transpilation (and ergo TypeScript) are already going to suffer from this now.  There is a very good reason why the MID should be decoupled from the actual physical filesystem/URI.  As you are pointing out, bundling and build optimisation, transpilation, etc can make a MID with an extension something totally inane.\r\n\r\nThis also throws up whole issues with those of us using CommonJS/AMD/UMD.  TypeScript is going to have to try to start trying to rewrite MIDs based on the packaging target...\r\n\r\nMy advice would be to wait at least to see what comes out of TC39 in regards to this.  If that gets adopted then, it gets adopted and we all have to deal with it.  Does anyone know what the plan with TC39 is?"}}