frankwallis / plugin-typescript

TypeScript loader for SystemJS
MIT License
248 stars 47 forks source link

Typing resolutions #102

Closed guybedford closed 8 years ago

guybedford commented 8 years ago

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.

Firstly, jspm-npm will handle conversion of npm packages converting the Node resolution algorithm into the SystemJS resolution algorithm.

Are 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?

guybedford commented 8 years ago

The above typings metadata can also be added with a meta override into the jspm registry for 0.17. Let me know if you'd like help with that at all.

tamird commented 8 years ago

@guybedford if this information was in the jspm registry, it'd end up in my generated config.js, correct?

If that's the case, why doesn't (or can't) jspm read package.json and populate the same thing? Seems to me that the jspm registry ought to be for overriding packages' own information as opposed to housing copies thereof.

bmayen commented 8 years ago

@frankwallis, you mentioned that "the algorithm TypeScript uses for finding external typings cannot be used from within a browser as it involves trawling the file system". Would it be possible to support this for precompilation builds and only require the additional configuration for the browser?

frankwallis commented 8 years ago

@bmayen it would be possible, but I am reluctant to go down that route as it would mean the file resolution worked completely differently in the 2 scenarios and that would be a constant source of issues. It seems to me that if you are using that workflow then you may be better off type-checking with tsc and just transpiling with the plugin?

frankwallis commented 8 years ago

I have added a new compiler option typings to enable easier configuration of packages with external typings contained within. See here for more info.

Also plugin-typescript now supports the types option for when you have installed typings from the @types scoped packages. See here for more info.

I am going to close this issue now, if you find issues with either of these features then please raise them separately.