-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
v4 to v5 | Problem with sequelize structure, Sequelize module methods auto-complete not working #11250
Comments
I don't know how we can control VS-Code auto complete but perhaps #8616 (comment) could help? |
Duplicate of #11103 |
@sushantdhiman @papb You didn't understand.. Assume I have created a model named Earlier I used to get suggestion like I am not talking about sequelize module auto-complete, it works! It's not a duplicate issue!!! |
@neilveil Sorry for the confusion. I have reopened it. Do you think an improvement in the typescript typings could solve this issue? |
@neilveil May be it will be better if you can share some code for which auto complete does not work. I still don't see how sequelize can fix auto-complete issues for an editor |
I'm also experiencing this... I've just upgraded sequelize-typescript v4 to v5 and in v5 sequelize-typescript uses the native sequelize typescript mappings... The issue seems to be that for example the CreateOptions does not take the model as input and therefor does not know the class attributes. If CreateOptions could receive a model of type - It would work :) Check on this line: sequelize/types/lib/model.d.ts Line 1916 in 488c048
|
@aat2703 As @sushantdhiman said, can you show a real example of the autocomplete not working that we can reproduce? |
Inside the fields: [] attributes cannot be auto-completed or recognized by the IDE. The same is the issue for findOne with the where attributes etc... Bookings.create(
event.body.booking,
{
fields: [
'state',
'type',
'startDate',
'endDate',
'name',
'phone',
'email',
'guests',
'note',
'walkIn'
],
include: [
{
model: Tables,
as: 'tables',
association: 'tables'
},
{
model: BookingTableLinks,
as: 'setTables',
attributes: [
'tableID'
]
}
]
}
) |
@aat2703 You mean this? Autocomplete should work here? |
Webstorm cannot find the declaration? This works with sequelize-typescript v4 interfaces which generally makes much more sense than native sequelize interfaces... IFindOptions takes a generic model as parameter... And therefor can be a lot more helpful for IDE's Lets look at the difference sequelize-typescript declaration: sequelize declaration: sequelize/types/lib/model.d.ts Lines 1791 to 1795 in 488c048
|
@aat2703 Can you guide me on how to make this intellisense work? |
Making FindOptions take a generic type and pass it into the WhereOptions. This would make auto-completion work anywhere. What do you think? export type WhereOptions<M> = WhereAttributeHash | AndOperator | OrOperator | Literal | Where | M;
public static findOne<M extends Model>(
this: { new (): M } & typeof Model,
options?: FindOptions<M>
): Promise<M | null>;
public static findOne<M extends Model>(this: { new (): M } & typeof Model, options: NonNullFindOptions): Promise<M>; |
@aat2703 Thanks for the snippet, although I have to apologize because I wasn't clear... I wanted to ask something else... What I wanted to ask is: is the behavior you want currently achievable somehow? Some specific IDE, some specific version of sequelize, sequelize-typescript, etc? |
Yeah, it works great with sequelize-typescript v0.6.11 & sequelize v4.43.2 Its because sequelize-typescript < 1 implements its own interfaces that works as i've described above. Starting from sequelize-typescript >= 1 and sequelize version 5.x.x it uses native sequelize typescript interfaces |
@aat2703 ah, I see! Would you be willing to submit a PR? |
Yeah, i'm working on it right now actually 👍 |
@papb any update? |
@maidanskyi I don't know, @aat2703 was apparently working on it but I don't know the state of their work |
I've previously used https://github.com/RobinBuschmann/sequelize-typescript to make this happen... and it works nicely... why not look at how it is implemented there and reuse it in the core of sequelize? We would like to sponsor someone to implement this.... |
Hi @ThomasEg, perhaps @RobinBuschmann himself would have an idea on an easy way to do this? I am completely out of time currently |
Hey, I'm not 100% sure what this issue is exactly about, but type safety and auto completion for model creation is already addressed with this PR #11820 Regarding |
Thanks for chiming in @RobinBuschmann !
This is correct |
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
There have been a lot of improvements to the typescript typings since this issue was first opened. I think |
I'm a developer and I've been using sequelize from last few years. MySQL, MSSQL etc are so vast and updating, I understand that it's hard to cover everything in one ORM. You must have resolved a lot of things in v5 but there is a serious issue that I'm facing right now is auto-complete feature in my code editor (VS code). It might not a big thing for you but for me as a developer it's huge because we developers are totally dependent on this small feature which is removed in v5 as now we are extending sequelize models class. And just because of this I don't want to migrate to v5, it's really useless for me.
The text was updated successfully, but these errors were encountered: