Reputation: 13
I am new to Stackoverflow, this is my very first question ever, I'm not sure how it all works yet, and I hope I will be able to explain my problem correctly. I was trying to use jQuery in vscode, so I installed Node.js, and then followed this tutorial on youtube; I typed npm install tsd -g
, then npm install typings --global
, and finally typings install dt~jquery --global
in my terminal, as the guy in the tutorial said, and eventually the folder: "typings" appeared into project folder.
.
After that, the guy copied the content of the last file, called "index.d.ts", which in my case contained /// <reference path="globals/jquery/index.d.ts" />
, into the "plugins.js" file, stored in the JS folder. As you can see, I do not have that folder and that file. What do I have to do? Have I committed a mistake in creating the whole project, or do I have to create a JS folder from scratch? And if so how? I know very little about vscode and jQuery, typescript... I hope someone can help, Thanks in advance.
Upvotes: 1
Views: 5899
Reputation: 6162
I'll try to explain on file structure similar to yours
With the last command we generated typings
folder. Inside typings/globals/jquery/index.d.ts
you can see Typescript declarations that will be used for suggestions in VS Code:
Now we need to modify our index.js
to use these typings. With arrows I am showing how import works. We add reference path for typings/index.d.ts
. typings/index.d.ts
just reexports typings from globals/jquery/index.d.ts
(see /// <reference path="globals/jquery/index.d.ts" />
inside it).
After making this kind of chaining, we can type in our js file and have automatic suggestions
Upvotes: 2