sequelize icon indicating copy to clipboard operation
sequelize copied to clipboard

Sequelize intellisense doesn't work in Visual Studio Code

Open pavledev opened this issue 7 years ago • 42 comments

What are you doing?

I installed sequelize package inside Visual Studio Code and I imported it. Then I typed command new Sequelize and I opened brace and intellisense didn't appear. I also tried to define model and after typing model name and dot intellisense again didn't appear. How to fix this problem?

Environment

Dialect:

  • [x] mysql
  • [ ] postgres
  • [ ] sqlite
  • [ ] mssql
  • [ ] any Dialect library version: mysql2 1.6.5 Database version: XXX Sequelize version: 5.8.9 Node Version: v11.12.0 OS: Windows 10 x64 If TypeScript related: TypeScript version: XXX Tested with latest release:
  • [ ] No
  • [ ] Yes, specify that version:

pavledev avatar Jun 23 '19 13:06 pavledev

I have the same problem here.

kuskhan avatar Jun 25 '19 22:06 kuskhan

same. vs code version - 1.35.1(latest)

raghavgrover21 avatar Jul 01 '19 18:07 raghavgrover21

I'm having the same problem - VS Code v1.35.1

Platiplus avatar Jul 03 '19 20:07 Platiplus

Me too. image

Flippittiflop avatar Jul 06 '19 19:07 Flippittiflop

Same but now on Version: 1.36.1

renecruzATX avatar Jul 10 '19 16:07 renecruzATX

This looks like a bug with VSCode to be honest... I just tried to reproduce, and the following happened:

  1. I installed Sequelize on an empty local folder and tried to reproduce this problem, and reproduced it successfully

  2. I navigated to node_modules/sequelize/types/index.d.ts and opened it as a new tab in VSCode and then closed it

  3. I went back to my JS file and intellisense magically started working.

Can anyone check if this "solves" the problem as well? @kuskhan @raghavgrover21 @Platiplus @Flippittiflop @renecruzATX

papb avatar Jul 11 '19 23:07 papb

@papb no its not working, tried it with my 2 projects just to be sure.

raghavgrover21 avatar Jul 12 '19 12:07 raghavgrover21

This looks like a bug with VSCode to be honest... I just tried to reproduce, and the following happened:

  1. I installed Sequelize on an empty local folder and tried to reproduce this problem, and reproduced it successfully
  2. I navigated to node_modules/sequelize/types/index.d.ts and opened it as a new tab in VSCode and then closed it
  3. I went back to my JS file and intellisense magically started working.

Can anyone check if this "solves" the problem as well? @kuskhan @raghavgrover21 @Platiplus @Flippittiflop @renecruzATX

That didn't solved the issue for me, the intellisense works on previous versions, but not in latest stable or 6.0.0.

What worked for me but it doesn't make sense is the following:

image

Using "const Sequelize = require('sequelize').Sequelize;" works.

But that only works in the connection file, when you try to import it for the modules, the autocomplete kind of works when you don't use this syntax. I'm really lost here hahaha

Platiplus avatar Jul 12 '19 12:07 Platiplus

@raghavgrover21 @Platiplus thanks for the replies. I am lost too. After I did what I said above, it started working and I can't reproduce the problem anymore. It started working for me magically...

papb avatar Jul 12 '19 13:07 papb

This looks like a bug with VSCode to be honest... I just tried to reproduce, and the following happened:

  1. I installed Sequelize on an empty local folder and tried to reproduce this problem, and reproduced it successfully
  2. I navigated to node_modules/sequelize/types/index.d.ts and opened it as a new tab in VSCode and then closed it
  3. I went back to my JS file and intellisense magically started working.

Can anyone check if this "solves" the problem as well? @kuskhan @raghavgrover21 @Platiplus @Flippittiflop @renecruzATX

That didn't solved the issue for me, the intellisense works on previous versions, but not in latest stable or 6.0.0.

What worked for me but it doesn't make sense is the following:

image

Using "const Sequelize = require('sequelize').Sequelize;" works.

But that only works in the connection file, when you try to import it for the modules, the autocomplete kind of works when you don't use this syntax. I'm really lost here hahaha

I tried this way and it worked. Thank you very much @Platiplus

pavledev avatar Jul 12 '19 15:07 pavledev

Beautiful! Thanks @Platiplus! It worked like a charm. I have a database JS file that I created and that is where I deployed this trick. Anywhere I import that database file the Intellisense works fine. The hive mind works again!

renecruzATX avatar Jul 12 '19 16:07 renecruzATX

It works if you import const Sequelize = require("sequelize").Sequelize in the main connection file where you make connection to your database.

sarifmiaa avatar Jul 16 '19 06:07 sarifmiaa

const Sequelize = require("sequelize").Sequelize gets intellisense partly working, but (for me) intellisense is still not working within functions such as create.

timstrasser avatar Jul 17 '19 19:07 timstrasser

Similar to #8616

papb avatar Jul 30 '19 13:07 papb

On VSCode Version 1.36.1, it's also buggy but this one works const Sequelize = require('sequelize').Sequelize;

Thanks, @Platiplus

IvanJasenov avatar Aug 03 '19 11:08 IvanJasenov

Observe that const { Sequelize } = require('sequelize'); is more readable (IMO).

papb avatar Aug 03 '19 12:08 papb

This should also work. import { Sequelize } from 'sequelize';

nnaynnay avatar Aug 18 '19 13:08 nnaynnay

I confirm the problem in vscode 1.37.1 under Windows 10

sulian avatar Aug 20 '19 12:08 sulian

@sulian Does

const { Sequelize } = require('sequelize');

instead of

const Sequelize = require('sequelize');

fix it for you?

papb avatar Aug 20 '19 13:08 papb

Thanks , it works if we use

const { Sequelize } = require('sequelize'); instead of

const Sequelize = require('sequelize');

SriSasanka8074 avatar Aug 29 '19 05:08 SriSasanka8074