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

Internal Bluebird promise is not compatible with es6 Promise interace #78

Closed
rokoroku opened this issue Nov 14, 2016 · 3 comments
Closed

Comments

@rokoroku
Copy link
Contributor

rokoroku commented Nov 14, 2016

#When I tried to make a method that wraps model methods and return with default es6 Promise interface (declared from lib.es6.d.ts), it returns incompatible type error:

[ts] Bluebird<Model> is not compatible with Promise<Model>

So I changed promise.d.ts file like this

import * as Bluebird from 'bluebird';

export const Promise: typeof Bluebird;
// export type Promise<T> = Bluebird<T>;
export default Promise;

then the error has gone.

Consider this issue :)

@rokoroku rokoroku changed the title Internal Promise<T> is not compatible with es6 Promise interace Internal Bluebird promise is not compatible with es6 Promise interace Nov 14, 2016
@felixfbecker
Copy link
Collaborator

I also met this issue before, but what you did cannot be considered a fix. You changed the file so that instead of exporting a Bluebird promise, you are just exporting a plain ES6 Promise. Which means all methods in Sequelize are now typed as returning a plain ES6 promise, and you cannot use any of the bluebird methods on it (like .finally() etc).

Can you provide me a bit more details how the error occured? What code caused this, what TS version are you using and what Sequelize version?

@rokoroku
Copy link
Contributor Author

Oh, I know that it's not a fix, It's just workarounds for es6 syntax.

Regenerating the error message is quite easy. See below code:

import { Model } from 'sequelize';

export class MyModel extends Model {
  static getSomeModel(): Promise<MyModel[]> {
    return this.findAll({ where: { someProperty: true } });
  }
} 

in typescript v2.0.9, sequelize v4.0.0-1

Should we wait for bluebird typings takes es6 Promise compatable interface?

@felixfbecker
Copy link
Collaborator

@rokoroku typed-typings/npm-bluebird#34 (comment)

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

2 participants