kevinbeaty / any-promise

NOTE: You probably want native promises now
MIT License
179 stars 17 forks source link

Add TypeScript typings to project #21

Closed blakeembrey closed 8 years ago

blakeembrey commented 8 years ago

Closes https://github.com/kevinbeaty/any-promise/issues/18. I can add this as the first project to https://github.com/typings/typings/issues/480, when I get to it 😄 Hopefully that'll always give you somewhere you can get help, just in case. But you can always ping me with changes also, it's pretty easy to pick up.

kevinbeaty commented 8 years ago

Cool, thanks.

A couple more things. #19 added "registration shortcuts". These are just bare imports that don't export anything, e.g.:

require('any-promise/register/bluebird')

// is shorthand for
require('any-promise/register')('bluebird', {Promise: require('bluebird'))

Would there be any reason to add definitions for these shortcuts?

Also, #15 (optional import) is probably coming soon in some form. The interface is still being discussed so I'll probably bug you again when that lands.

Thanks again!

blakeembrey commented 8 years ago

@kevinbeaty Committed the changes. On the registration shortcuts, I've copied the plain Promise re-exporting. If, at some point, each promise implementation actually adds type definitions, you could import those and re-export those instead.

kevinbeaty commented 8 years ago

On the registration shortcuts, I've copied the plain Promise re-exporting.

I'm a bit confused now. Those shortcuts are used only for the side-effect of register, nothing is exported. Why do we declare it as exporting the Promise? (Or maybe it was just a misunderstanding?)

blakeembrey commented 8 years ago

@kevinbeaty Oh, I read it wrong - I thought it was exporting the promises directly. Let me double check.

blakeembrey commented 8 years ago

@kevinbeaty Switched it to empty exports so that the ES6 import will work (E.g. import 'any-promise/register/bluebird'). Module augmentation with global doesn't currently work, so it won't magically appear in the global with TypeScript (yet).

kevinbeaty commented 8 years ago

Cool thanks. Do you recommend anything to help test definitions are correct? If not, I can take your word for it on this one, but it certainly would be nice.

blakeembrey commented 8 years ago

Only using the TypeScript compiler itself, that would ensure they're correct (but not functionally correct).

blakeembrey commented 8 years ago

Awesome, cheers! Looking forward to this release, I have a few modules to update now 😄

kevinbeaty commented 8 years ago

Published in v 1.3.0