Closed sebastianwahn closed 6 years ago
Hi @sebastianwahn,
I can't reproduce this issue 🙁 Let's try to change typeof Model
into typeof Cat
and let me know
Hi @kamilmysliwiec
I had the same issue and when I change typeof Model
into typeof Cat
, that error disappeared.
Thanks!
@kamilmysliwiec Thanks for the tip! I thought i tried this one already, but this solves it for 0.6.1
Unfortunately, this will still fail for people using the nest-starter and follow the code example on the page/repository (like I did).
So the best thing would be to update the example on the page to use typeof Cat
and to update the code for example 07 to use 0.6.1 and also typeof Cat
.
I have updated the example already, now the docs part 💪
Hi @kamilmysliwiec - I have exactly the same issue, but I'm using a Base Model and BaseService class.
`
export abstract class BaseService
constructor(protected readonly repository: Repo...`
So the model type is passed in from each extended service. How can I set repository
type to a generic Model?
I know this isn't specific to NestJS, but I can't find any issue as similar as this thread..
Did you figure out a way to setup a generic type? with possible overrides?
ie. getModel(): Model<dog,any>; getModel(): Model<cat,any>;
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'm submitting a...
Current behavior
When using the nest starter boilerplate code, the version
0.6.1
for package"sequelize-typescript":"^0.6.1"
is used.In example 07 regarding the integration of sequelize, following code is provided as an example to use the repository:
Although, when checking the code of the example, it uses version
0.5.0
of"sequelize-typescript": "^0.5.0",
In the
0.5.0
the code example works fine, when using the starter code (which uses0.6.1
) following TypeScript compiler error show up:Error:(12, 22) TS2684: The 'this' context of type 'typeof Model' is not assignable to method's 'this' of type 'new () => Cat'. Cannot assign an abstract constructor type to a non-abstract constructor type.
Expected behavior
The code example shows how to work with a current version of
sequelize-typescript
, which is used in the starter.Minimal reproduction of the problem with instructions
sequelize-typescript
to version0.6.1
TS2684
What is the motivation / use case for changing the behavior?
Clear and foolproof example on how to work with nest and sequelize. Furthermore, reduction of debugging time for other developers.
Workaround
Use version
0.5.0
ofsequelize-typescript
instead of0.6.1
initially set by the nest starter.Environment
Further information
The problematic code is
export declare abstract class Model<T> extends Hooks {
introduced in https://github.com/RobinBuschmann/sequelize-typescript/commit/cc95b82eb49bd1b41d844b2c37744f4b52883938#diff-1c485f95a55d5ce0466f63a966ced297R25