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

Sequelize types being imported inside sequelize-typescript types are inferred to any #797

Open
swordman1205 opened this issue Jun 11, 2020 · 4 comments

Comments

@swordman1205
Copy link

swordman1205 commented Jun 11, 2020

Versions

  • sequelize: 5.21.11
  • sequelize-typescript: 1.1.0
  • typescript: 3.9.3

I'm submitting a ...

[x] bug report
[ ] feature request

Actual behavior:

I am creating sequelize models as a shared lib for microservice-like backend architecture so the models can be imported over multiple repos. Our backend is coded with Typescript so I used sequelize-typescript to support TS in the shared model repo. Everything seems working well, but actually every sequelize types being used inside sequelize-typescript types are inferred to any in my microservice repos.

Expected behavior:

I would like to get all the shared functions and variables output with accurate sequelize types. I spent a couple days on this issue for investigation. Look microsoft/TypeScript#23918

Steps to reproduce:

Related code:

My shared model example:

import { Model, Table } from 'sequelize-typescript';

@Table({
  timestamps: true,
  underscored: true,
  tableName: 'members'
})
export class Members extends Model {
  // Columns
  ...
}

How to use the model above in my backend repos:

import { Members } from '@xxx/models';
...
const member = await Members.findOne({
  where: { xx: xx }
}); // member is inferred to any. findOne function should be inferred to Promise<Member>.

Thank you for your help in advance @RobinBuschmann

@zcong1993
Copy link

same problem

@ertwroc
Copy link

ertwroc commented Aug 3, 2020

Solution: #575 (comment)
I've just tested it and works fine (had the same problem).
Issue can be closed.

@LucasLundJensen
Copy link

I'm still having this exact issue, even after installing Bluebird types.

@LucasLundJensen
Copy link

For anyone who stumbles into this one, an explanation is given here: #858

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

4 participants