Definitelytyped: @types/bluebird forces a compiler upgrade

Created on 1 Jul 2017  路  7Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/xxxx package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @fengb @well1791 @andy-ms

The @types/bluebird package was recently changed such that it requires the TypeScript 2.3 compiler. It also has an undocumented dependency on ES2015.Collection, i.e. I need to a use a command-line like this:

tsc example.ts --lib DOM,ES5,ScriptHost,ES2015.Collection

With TypeScript 2.2.2, I get this error:

node_modules/@types/bluebird/index.d.ts(50,17): error TS1005: ',' expected.
node_modules/@types/bluebird/index.d.ts(50,31): error TS1005: ',' expected.

With TypeScript 2.3.4, the error goes away.

Although it's nice to always be on the bleeding edge, not everyone has that luxury. My group is responsible for around 100 projects that build using a common tool chain. Last time we upgraded the TypeScript compiler, it took us an entire week to migrate everything, and then we also needed to publish migration instructions for our third party developers. Thus, even though TypeScript version 2.2.2 seems "ancient", three months is pretty new from the perspective of a core library like Bluebird that should support as broad an audience as possible.

We have worked around this problem by downgrading to an older version of @types/bluebird. However, downgrading itself was problematic, since we didn't have an explicit dependency on Bluebird. We got accidentally upgraded because DefinitleyTyped packages have unconstrained version numbers for their dependencies.

Most helpful comment

@dearibujar npm install @types/[email protected]

All 7 comments

Looks like we added these dependencies:

  1. Default type arguments for .then<TResult1 = T>() _(TS 2.3)_
  2. .props(Map) _(ES2015.Collection)_ or _(ES6)_
  3. .props(object & {}) _(TS 2.2)_
  4. .props({ [K keyof T] }) _(TS 2.1)_

1 can be reimplemented in 2.1 semantics, but I'm not quite sure about 2 + 3. I can give it a shot though.

Thanks!

Seems like this was intentionally changed to match the standard (2.3) PromiseLike definition: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17245

I'm disinclined to revert this...

@lhecker any ideas on how to resolve? It'd be extremely nice if there was a standard type that coerces PromiseLike into any Promise implementation but I think that's foregone for backwards compatibility.

@fengb @pgonzal I don't think this issue can be "solved". The only regrettable part is rather that we didn't push out a new semver major version when we made Bluebird TypeScript v2.3+ only. Instead it'd probably be for the best if https://github.com/Microsoft/types-publisher/issues/360 is solved soon.

Reason being: Compatibility with PromiseLike is (or will be) an important feature for Bluebird, so we absolutely cannot revert this. The dependency on ES2015.Collection is also regrettable, but Bluebird conditionally checks for the existence of ES6 Maps and supports them if that's the case. Since TypeScript has no "easy" tools for conditional compilation we had to add it unconditionally to the typings. In general this shouldn't pose a problem though right?

AFAIR it should be possible to do simple version pinning with NPM though, which should solve this issue in the meantime, right?

Thanks for investigating. We have worked around the problem, and will upgrade our compiler in the next month or two, at which point this particular issue will no longer affect us.

Would it be possible for you to introduce a mechanism to prevent these breaks in the future? e.g. establish a baseline compiler version that you want to target for backwards compatibility, and require people to build it before merging a PR? Thanks!

Is there a fix or workaround for this?

@dearibujar npm install @types/[email protected]

Was this page helpful?
0 / 5 - 0 ratings