Sequelize types being imported inside sequelize-typescript types are inferred to any
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 https://github.com/microsoft/TypeScript/issues/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
same problem
Solution: https://github.com/RobinBuschmann/sequelize-typescript/issues/575#issuecomment-478235968 I've just tested it and works fine (had the same problem). Issue can be closed.
I'm still having this exact issue, even after installing Bluebird types.
For anyone who stumbles into this one, an explanation is given here: #858