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

[@types/node@13] global.Promise = Bluebird gives Symbol.species missing error #42084

Closed
4 tasks done
medington opened this issue Feb 4, 2020 · 4 comments
Closed
4 tasks done

Comments

@medington
Copy link

medington commented Feb 4, 2020

There appears to be a new incompatibility between the @types/node@13 with Bluebird Promises.

In @types/node@12 release it was possible to assign to the global Promise object using:

global.Promise = bluebird

However, in @types/node@13 this now generates a compiler error:

src/index.ts:4:1 - error TS2741: Property '[Symbol.species]' is missing in type 'typeof Bluebird' but required in type 'PromiseConstructor'.

global.Promise = bluebird

  node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:173:14
    173     readonly [Symbol.species]: PromiseConstructor;

We have dependabot configured for our repo and this same issue has appeared in every v13 release of @types/node so far.

Steps to reproduce:
I created a test project which makes this easy to reproduce:

git clone git@github.com:medington/node-typing-issue.git && cd node-typing-issue
npm install
npm run build

If you know how to fix the issue, make a pull request instead.

@SimonSchick
Copy link
Contributor

This appears to be due to v13 depending on new TS libs (which would be the root issue here) and that's not something I can (or am willing to) fix.
The easiest workaround is probably global.Promise = <any>Bluebird.

@medington
Copy link
Author

Thanks for the quick feedback @SimonSchick ! Totally understood. I mostly wanted to get this issue logged so that others who may run into it will have a reference. I was honestly a bit surprised no one else has in the month since v13 was released.

For our project, I'll probably install bluebird-global which is a micro package that makes the assignment. Advantage there is you can put that import first and ensure it's replaced as early in app startup as possible. It'll also avoid the <any> cast and the directive to ignore it in strict mode with noImplicitAny.

I actually spent some time looking at the diffs between the v12 and v13 source and could not for the life of me see anything obvious in the changes to account for the error. I suspected it may have been related to a lib change, but don't know enough about how those get pulled in to confirm that.

Do you think that this is something that I should also report to Bluebird typing authors? Is this something that they can / should try to address? At the very least it might be worth a readme entry or comment somewhere in the code.

Thanks again for you time and your contribution! Have a great day.

@SimonSchick
Copy link
Contributor

I guess bluebird (not the typings) could specify Symbol.species which would make the implementations compatible again and the typings could be adjusted accordingly.

Personal note: I find Symbol.species kind of confusing, it seems to be more or less an alias of the constructor property.

@orta
Copy link
Collaborator

orta commented Jun 7, 2021

Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the @types modules in DefinitelyTyped.

To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the definitely-typed channel.

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

3 participants