Skip to content

typings: Consider using PromiseLike instead of Promise #960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
unional opened this issue Jul 12, 2016 · 6 comments
Closed

typings: Consider using PromiseLike instead of Promise #960

unional opened this issue Jul 12, 2016 · 6 comments

Comments

@unional
Copy link

unional commented Jul 12, 2016

Using the global Promise causes incompatibility error:
unional#1

Using PromiseLike should solve this problem.

@jamestalmage
Copy link
Contributor

See microsoft/TypeScript#5911

It seems to suggest that Promise must be used for async functions. We definitely want to allow async functions, so not sure this is a good idea.

@SamVerschueren @ivogabe

@unional
Copy link
Author

unional commented Jul 12, 2016

An alternative would be using any-promise. Since it includes its typings and does not have any dependencies, it should work too.
You can try it out with the changes I made:

I add any-promise and solve the issue:
https://github.com/unional/ava/blob/master/index.d.ts#L1
https://github.com/unional/ava/blob/master/package.json#L80

@unional
Copy link
Author

unional commented Jul 13, 2016

es6-promise would also be possible (and likely a better option) once this is landed:
stefanpenner/es6-promise#211

@ivogabe
Copy link
Contributor

ivogabe commented Jul 13, 2016

PromiseLike would work, there's no need to add another dependency for it.

@jamestalmage That only applies when you annotate an async function with a return type. Promise<T> is assignable to PromiseLike<T>, so you can still use async functions after this change.

ivogabe added a commit to ivogabe/ava that referenced this issue Jul 13, 2016
@sindresorhus
Copy link
Member

Fixed by 1dd6d5b.

@unional
Copy link
Author

unional commented Jul 13, 2016

Great! Thanks.

I'm working on ava-fixture in typescript that runs file-based tests (and baseline tests in the future). It would benefit from the updated typings.

Are you planning to do a release soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants