These are chat archives for TypeStrong/atom-typescript

3rd
May 2015
Micah Zoltu
@MicahZoltu
May 03 2015 00:37
I am using JSPM for dependency management and SystemJS for module loading. I have installed oauth.io with JSPM. This results in jspm_packages/oauth.io@0.4.0.js being created. In ES6, I can do import OAuthIo from 'oauth.io' and everything works out, because there is no compile-time resolution necessary. I am trying to move over to TypeScript, but that line now fails in atom-typescript because it can't find the 'oauth.io'. This isn't surprising because TypeScript doesn't have any way of finding my JSPM dependencies.
Are there any patterns that people are following to deal with this sort of thing? Presumably I will need to author a .d.ts, where would I put it? If I distribute my .d.ts as a JSPM package, I'll be right back in this situation of atom-typescript not being able to find the definition file.
What I would like to do is somehow teach typescript (in general) about JSPM so when it sees oauth.io it can resolve the mapping that JSPM creates in config.js, find the installed folder, and pull the .d.ts file out.
So, even if I do get the d.ts issue resolved, I still have the issue that I need the compiled ES6 file to have the import in it (System.register(['oauth.io'] ...) so everything works at runtime. How can I get atom-typescript to stop complaining about it?
Micah Zoltu
@MicahZoltu
May 03 2015 05:33
(my question may actually be about TypeScript, the line between one and the other are not completely clear to me)
Nelo Mitranim
@Mitranim
May 03 2015 17:48
@Zoltu My solution to this sort of thing was to use DefinitelyTyped
install the tsd tool, use it to install definitions for the third party libraries you use, and add its typings folder to your filesglob
Micah Zoltu
@MicahZoltu
May 03 2015 17:49
Correct me if I am wrong, but that doesn't solve the problem of the fact that I need to import oauth.io.js in my ES6 file.
Nelo Mitranim
@Mitranim
May 03 2015 17:49
huh why is that a problem
Micah Zoltu
@MicahZoltu
May 03 2015 17:49
Essentially, I have two problems, one is what is the pattern for getting typings, which is where TSD comes in.
Nelo Mitranim
@Mitranim
May 03 2015 17:49
you need to get hold of it to use it, don't you
Micah Zoltu
@MicahZoltu
May 03 2015 17:49
The other is that I am actually using ES6 imports, which TS can't validate.
Nelo Mitranim
@Mitranim
May 03 2015 17:50
I'm using ES6 imports with atom-typescript as well, and using definitelytyped solves the problem
Micah Zoltu
@MicahZoltu
May 03 2015 17:50
jspm install oauth.io;
import OAuth from 'oauth.io';
Nelo Mitranim
@Mitranim
May 03 2015 17:50
It provides module definitions
Micah Zoltu
@MicahZoltu
May 03 2015 17:50
oauth.io is a JavaScript library.
Nelo Mitranim
@Mitranim
May 03 2015 17:50
everything we write is javascript...
Micah Zoltu
@MicahZoltu
May 03 2015 17:50
When typescript sees that import line it complains because it can't finde oauth.io.
Nelo Mitranim
@Mitranim
May 03 2015 17:51
Yes, it does until you add typings from tsd
just try it
Micah Zoltu
@MicahZoltu
May 03 2015 17:51
Are you implying that if I had a d.ts for oauth.io brought in through TSD, TypeScript would stop complaining?
Nelo Mitranim
@Mitranim
May 03 2015 17:51
The thing is, if you want atom to pick up the actual source of that library and parse it for definitions, you're out of luck. This won't happen until third party libraries are distributed as TypeScript
Micah Zoltu
@MicahZoltu
May 03 2015 17:52
Where does TSD put its downloaded d.ts files?
Nelo Mitranim
@Mitranim
May 03 2015 17:52
For now, we need to rely on abstract definitions from tsd. They actually declare modules and TypeScript checks them against your import declarations
Micah Zoltu
@MicahZoltu
May 03 2015 17:52
And how does TypeScript know how to find them?
Nelo Mitranim
@Mitranim
May 03 2015 17:52
via filesglob
Micah Zoltu
@MicahZoltu
May 03 2015 17:52
A filesglob in tsconfig.json?
Nelo Mitranim
@Mitranim
May 03 2015 17:53
yep
your atom-typescript will automatically add those files to the files array in tsconfig
if you're using the typescript compiler, it may or may not pick on this files
I'm using babel so dunno
Micah Zoltu
@MicahZoltu
May 03 2015 17:53
Ah, okay. So a file named oauth.io.d.ts will be downloaded, added to the files list, then the TypeScript compiler will read that and load it up and be able to resolve it..
Nelo Mitranim
@Mitranim
May 03 2015 17:54
yeah
Micah Zoltu
@MicahZoltu
May 03 2015 17:54
What happens if there is a name conflict?
That is, how is namespacing handled?
Nelo Mitranim
@Mitranim
May 03 2015 17:54
beats me