sequelize / sequelize-typescript

Decorators and some other features for sequelize
MIT License
2.79k stars 280 forks source link

type infer problem when using version 1.0.0 #587

Closed alsotang closed 5 years ago

alsotang commented 5 years ago

I write this demo project

npm i sequelize-typescript sequelize
// main.ts
import { Table, Column, Model, Default, PrimaryKey } from 'sequelize-typescript';

@Table({
  tableName: 'wmuser',
  timestamps: true,
  paranoid: true,
})
export class UserModel extends Model<UserModel> {
  @PrimaryKey
  @Column
  id!: string;

  @Column
  token!: string;
}

UserModel.create().then(vvvvvv => {

})

typescript can not infer the type of vvvvvv. Its type is `any.

When I run npm install @types/bluebird, the type infer works

alsotang commented 5 years ago

Seems it is not sequelize-typescript bug. It is a bug of sequelize. But I believe a lot users using this library would face the bug. https://github.com/sequelize/sequelize/issues/10668

RobinBuschmann commented 5 years ago

Hey @alsotang, we already discussed that here #575. It is not a bug, the requirement to install @types/bluebird is mentioned in the docs (http://docs.sequelizejs.com/manual/typescript.html). But I agree that this is not very obvious. We consider adding @types/bluebird to peerDependencies

alsotang commented 5 years ago

ok, but the docs is not obvious. and I mistakenly thought it's the problem of beta version of sequelize-typescript