-
Notifications
You must be signed in to change notification settings - Fork 37
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
Changed type of return value of Model<TInstance, TAttributes>.scope
#14
Conversation
Changed type of return value of `Model<TInstance, TAttributes>.scope` from `this` to `Model<TInstance, TAttributes>`. The following example in https://github.com/Thylossus/sequelize-pull-request-justification-demo/tree/master tries to mimic the example from https://github.com/louy/typed-sequelize/blob/master/README.md. However, I cannot compile this example due to a type error: ``` index.ts(16,16): error TS2322: Type 'sequelize.Model<Thing, ThingInstance>' is not assignable to type 'sequelize.SequelizeStaticAndInstance.Model<Thing, ThingInstance>'. Types of property 'scope' are incompatible. Type '(options?: string | string[] | ScopeOptions | WhereOptions) => Model<Thing, ThingInstance>' is not assignable to type '(options?: string | string[] | ScopeOptions | WhereOptions) => this'. Type 'Model<Thing, ThingInstance>' is not assignable to type 'this'. ``` This is probably related to microsoft/TypeScript#5863. Changing the return type of `scope` solves the error for me. Of course, this is not a sufficient criterion for changing your code, but I believe that isn't working for anyone. Feedback about the correctness of this assumption is very welcome. Thank you for providing the typings!
Your type arguments are switched, it's |
This is a typo in the readme file. it should be |
But that doesn't change the error though. It can't be related to the issue you linked as |
@louy Reopening because that doesn't solve this issue ;) |
Thank you for your responses. I've updated my code in https://github.com/Thylossus/sequelize-pull-request-justification-demo/tree/master. Nonetheless, the issue remains. In accordance with https://github.com/louy/typed-sequelize/blob/master/index.d.ts#L5296, https://github.com/louy/typed-sequelize/blob/master/index.d.ts#L2578, and https://github.com/louy/typed-sequelize/blob/master/index.d.ts#L3468, I swapped The error is now
(basically the same error with |
Right @felixfbecker. So for some reason the return type of I'll take a look at it later today. It might be better to have this as an issue rather than a PR as this clearly doesn't fix it. |
@felixfbecker Oh, you are right, of course. |
@louy Okay, so should I close this PR and open an issue referencing this PR? |
Changed type of return value of
Model<TInstance, TAttributes>.scope
fromthis
toModel<TInstance, TAttributes>
. The following example in https://github.com/Thylossus/sequelize-pull-request-justification-demo/tree/master tries to mimic the example from https://github.com/louy/typed-sequelize/blob/master/README.md.However, I cannot compile this example due to a type error:
This is probably related to microsoft/TypeScript#5863. Changing the return type of
scope
solves the error for me.Of course, this is not a sufficient criterion for changing your code, but I believe that isn't working for anyone. Feedback about the correctness of this assumption is very welcome.
Thank you for providing the typings!