{"action":"created","issue":{"url":"https://api.github.com/repos/frankwallis/plugin-typescript/issues/102","repository_url":"https://api.github.com/repos/frankwallis/plugin-typescript","labels_url":"https://api.github.com/repos/frankwallis/plugin-typescript/issues/102/labels{/name}","comments_url":"https://api.github.com/repos/frankwallis/plugin-typescript/issues/102/comments","events_url":"https://api.github.com/repos/frankwallis/plugin-typescript/issues/102/events","html_url":"https://github.com/frankwallis/plugin-typescript/issues/102","id":131025885,"number":102,"title":"Typing resolutions","user":{"login":"guybedford","id":598730,"avatar_url":"https://avatars.githubusercontent.com/u/598730?v=3","gravatar_id":"","url":"https://api.github.com/users/guybedford","html_url":"https://github.com/guybedford","followers_url":"https://api.github.com/users/guybedford/followers","following_url":"https://api.github.com/users/guybedford/following{/other_user}","gists_url":"https://api.github.com/users/guybedford/gists{/gist_id}","starred_url":"https://api.github.com/users/guybedford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guybedford/subscriptions","organizations_url":"https://api.github.com/users/guybedford/orgs","repos_url":"https://api.github.com/users/guybedford/repos","events_url":"https://api.github.com/users/guybedford/events{/privacy}","received_events_url":"https://api.github.com/users/guybedford/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-03T13:29:34Z","updated_at":"2016-02-03T21:16:39Z","closed_at":null,"body":"It sounds like the resolution problems tackled in https://github.com/typings/typings/issues/123 are critical to this plugin's type checking feature. I'd be really interested to see what can be done to make this work, if you don't mind helping me understand this area a little better.\r\n\r\nFirstly, jspm-npm will handle conversion of npm packages converting the Node resolution algorithm into the SystemJS resolution algorithm.\r\n\r\nAre you saying that typings themselves are written assuming the Node resolution algorithm? Which assumptions are these usually based on? For example, are extensions usually used? Do directory requires or json requires get used? How exactly does SystemJS's naive import not work with this resolution currently?"},"comment":{"url":"https://api.github.com/repos/frankwallis/plugin-typescript/issues/comments/179472886","html_url":"https://github.com/frankwallis/plugin-typescript/issues/102#issuecomment-179472886","issue_url":"https://api.github.com/repos/frankwallis/plugin-typescript/issues/102","id":179472886,"user":{"login":"frankwallis","id":4387473,"avatar_url":"https://avatars.githubusercontent.com/u/4387473?v=3","gravatar_id":"","url":"https://api.github.com/users/frankwallis","html_url":"https://github.com/frankwallis","followers_url":"https://api.github.com/users/frankwallis/followers","following_url":"https://api.github.com/users/frankwallis/following{/other_user}","gists_url":"https://api.github.com/users/frankwallis/gists{/gist_id}","starred_url":"https://api.github.com/users/frankwallis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankwallis/subscriptions","organizations_url":"https://api.github.com/users/frankwallis/orgs","repos_url":"https://api.github.com/users/frankwallis/repos","events_url":"https://api.github.com/users/frankwallis/events{/privacy}","received_events_url":"https://api.github.com/users/frankwallis/received_events","type":"User","site_admin":false},"created_at":"2016-02-03T21:16:39Z","updated_at":"2016-02-03T21:16:39Z","body":"A little bit of background on TypeScript typings - originally .d.ts files were included using ```/// reference path=\"./typings/angular.d.ts\"``` comments in the source files which needed them. These **declaration** files contain external module declarations like this:\r\n\r\n```\r\ndeclare module \"angular\" {\r\n   function bootstrap(modules: Module[]);\r\n}\r\n```\r\n\r\nWhen you do ```import angular from \"angular\"``` TypeScript then finds the \"angular' module declaration and uses that for type-checking. This is quite straightforward for the plugin as it knows all the files which it needs to load to type-check a source file.\r\n\r\nRecently there has been change so that you can deliver **typings** files, these are a little different to the one above because the file itself is the module, so the one above would look like:\r\n\r\n```\r\nexport function bootstrap(modules: Module[]);\r\n```\r\n\r\nand when you do ```import angular from \"angular\"``` TypeScript will see that the \"angular\" package has a typings file and use that when type-checking the file. So how does it know whether the angular package has a typings file? Well the algorithm goes something like:\r\n\r\na) Look in package.json for \"typings\" field. If found use that.\r\nb) Resolve the imported .js file using node.js resolution and see if there is a .d.ts file of the same name\r\n\r\nRule (b) also applies when doing ```import router from \"angular/router\"```. The exact algorithm is described [here](https://github.com/Microsoft/TypeScript/issues/2338)\r\n\r\nSo this is the difficulty when loading tin the browser, because the plugin doesn't know which packages have typings files. SystemJS resolution can't be used because that needs to resolve to the .js file.\r\n\r\nAngular2 delivers multiple typings files in the npm package and this makes it impossible to type-check in the browser unless you switch back to using one of the old-style declaration files. Solving the angular2 problem ought to be the priority here I think.\r\n\r\nIf jspm could record any .d.ts files it finds when installing packages so that they were available somewhere in the runtime config then that might work, could jspm-npm do that? Otherwise the typings project may be able to provide this information but its not quite clear how that is going to pan out right now.\r\n\r\nI hope this is clearer and we can find a way forward.\r\n\r\n\r\n\r\n"}}