I'm testing the new code editor from Microsoft : Visual Studio Code.
I'm under Windows 7 and i'm trying this example : https://code.visualstudio.com/Docs/nodejs
But when i try to add /// <reference path="/typings/node/node.d.ts"/>
like it is said in the example. It does'nt work. The file is never downloaded and i don't know where i can find it.
Is someone knows how to fix that ? Is it a bug or the problem come from my machine ?
Use the search box to find the npm file, choose the npm Configuration File, use the default name, and click Add. If you don't see the npm Configuration File listed, Node. js development tools are not installed. You can use the Visual Studio Installer to add the Node.
TSD is TypeScript Definition, while TypeScript is a typed superset of JavaScript from Microsoft that compiles to plain JavaScript. You don't need to understand these if you just want to use VSCode to develop common JavaScript-based node.js projects like me.
To solve your problem, I think a better way is to install the TSD package manager as a global module. This will enable you to use the command tsd globally.
npm install tsd@next -g
Then go to the root folder of your project, and type
tsd install node
This will automatically create a folder 'typings/node' with a .ts file named 'node.d'.
If you also need IntelliSense for third party modules like express.js or async.js, you can just add them by yourself
tsd install express
Just like 'npm' which you already be familiar with is the package manager for node.js, 'tsd' is the package manager for TypeScript Definition (but not for TypeScript itself)
There's a list here showing the available repositories.
http://definitelytyped.org/tsd/
Once you download all the .tsd files into the 'typings' folder, you still have to manually put these special comments at the beginning of each .js files to help VSCode look up the definitions for node and express, so now VSCode knows the API details of the classes and functions.
/// <reference path="typings/node/node.d.ts"/>
/// <reference path="typings/express/express.d.ts"/>
I just tried last night and it worked fine.
You shouldn't put the reference by yourself. You should let VS Code do it for you by pressing "Ctrl + ." (thats the dot key you should press) on the marked __dirname and choosing the option for the TypeScript Definition file as said on the website.
VS Code will create the directories structure under your project folder, download the file and add the reference to your app.js express application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With