Skip to content
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

Move Promise<T> declaration to lib.es5.d.ts #14053

Merged
merged 6 commits into from
Feb 14, 2017
Merged

Move Promise<T> declaration to lib.es5.d.ts #14053

merged 6 commits into from
Feb 14, 2017

Conversation

mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Feb 13, 2017

Move the declaration of the Promise interface to es5.d.ts (and subsequently lib.d.ts). This allows for DOM APIs that return Promise to be typed accurately.

The PR adds a specialized error message for missing Promise value declaration while Promise type is available.

Fixes: #13947

@mhegazy mhegazy changed the title Use promise Move Promise<T> declaration to lib.es5.d.ts Feb 13, 2017
@mhegazy mhegazy merged commit c547f52 into master Feb 14, 2017
@mhegazy mhegazy deleted the usePromise branch February 14, 2017 19:17
@itaysabato
Copy link

Hey there @mhegazy,

Can you please tell me how do I, as of now, avoid taking the Promise interface definition just added to lib.es5.d.ts?

Up until 2.2.1, setting "lib": ["dom", "es5", "es2015.core"] did the job for me. Is there a way to achieve the equivalent?

Thanks!

@mhegazy
Copy link
Contributor Author

mhegazy commented Feb 27, 2017

I am afraid there is not a way to do this now. but this is only the interface Promise and not the value Promise. can you elaborate on your scenario?

@itaysabato
Copy link

Sure, I will gladly elaborate :)

The thing is I am using Bluebird as a polyfill for promises by setting the global Promise value to the bluebird module both in client code and in node. I am also using @types/bluebird for typings of their extensions to the Promise API.

The only way I found to avoid clashing between the "bundled" Promise type and bluebird is to exclude the former from tsconfig.

I have noticed the differentiation made between the Promise interface and value but have not been able to use that to my advantage... Semantically what I would like is to declare let Promise: typeof Bluebird; but that does not seem to work properly.

I would be happy to learn about any kind of solution or workaround.

Thanks again.

@itaysabato
Copy link

@mhegazy Do you have any new insights on this?
I would like to at least know if this is a bug or am I doing something wrong...

Thanks a lot!

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

Successfully merging this pull request may close these issues.

4 participants