I'm testing the new code editor from Microsoft : Visual Studio Code.
我正在测试微软的新代码编辑器:Visual Studio代码。
I'm under Windows 7 and i'm trying this example : https://code.visualstudio.com/Docs/nodejs
我在Windows 7下,正在尝试这个例子: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 ?
有人知道怎么解决吗?是虫子还是我的机器出了问题?
5 个解决方案
#1
24
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.
TSD是TypeScript定义,而TypeScript则是由Microsoft编译成普通JavaScript的一组类型的JavaScript。如果您只是想使用VSCode来开发通用的基于javascript的节点,那么您不需要理解这些。js项目喜欢我。
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.
为了解决您的问题,我认为更好的方法是将TSD包管理器安装为一个全局模块。这将使您能够使用全局命令tsd。
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'.
这将自动创建一个名为“node.d”的文件夹“typings/node”。
If you also need IntelliSense for third party modules like express.js or async.js, you can just add them by yourself
如果你还需要像express这样的第三方模块的智能感知。js或异步。js,你可以自己添加。
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)
您已经熟悉的“npm”是node的包管理器。js,“tsd”是TypeScript定义的包管理器(但不是针对TypeScript本身)
There's a list here showing the available repositories.
这里有一个显示可用存储库的列表。
http://definitelytyped.org/tsd/
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.
一旦您将所有的.tsd文件下载到“typings”文件夹中,您仍然需要在每个.js文件的开头手动放置这些特殊的注释,以帮助VSCode查找node和express的定义,所以现在VSCode知道类和函数的API细节。
/// <reference path="typings/node/node.d.ts"/>
/// <reference path="typings/express/express.d.ts"/>
#2
2
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.
你不应该把参考书放在自己的位置上。你应该通过按下“Ctrl + .”(你应该按下的点键)来为你做,在标记的__dirname上,并选择在网站上说的TypeScript定义文件的选项。
VS Code will create the directories structure under your project folder, download the file and add the reference to your app.js express application.
VS代码将在您的项目文件夹下创建目录结构,下载该文件并将引用添加到app.js express应用程序中。
#3
0
I had the same problem with angular and this is how I got it to work for me: It looks like the problem was that VSCode failed to download the file and create the directories. I googled angular.d.ts and found it on GitHub - DefinitelyTyped
我有同样的角度问题,这是我如何让它为我工作的:看起来问题是,VSCode没有下载文件并创建目录。我用谷歌搜索了angular.d。ts并在GitHub上找到它。
I created "typings/angularj/" folders and added the file and now intellisense is working for angular :)
我创建了“typings/angularj/”文件夹,并添加了文件,现在intellisense正在为棱角而工作:)
So just grab the "node.d.ts" file instead of from DefinitelyTyped and it should work for you as well.
所以只要抓住“node.d”。“文件”而不是“定义式”,它也应该为你工作。
#4
0
As @HenryLi mentioned, you need to get a file with type definitions for Node. However TSD has been deprecated for quite a while now. Worry not, however! Now the type definitions are managed directly by Microsoft and bundled right through npm
!
正如@HenryLi所提到的,您需要获取一个带有节点类型定义的文件。然而,TSD已经被弃用已经有一段时间了。但是,别担心!现在,类型定义由Microsoft直接管理,并将其绑定到npm!
To solve your problem, it's enough to run this command:
要解决您的问题,可以运行以下命令:
npm install --save -g @types/node
#5
-2
(Edit: VS Code needs me to open a directory, and not a single file to let intellisense work well)
(编辑:VS代码需要我打开一个目录,而不是一个文件让智能感知工作正常)
Same problem for me.
对我同样的问题。
This does not work:
这并不工作:
Add /// reference to 'node/node.d.ts'
添加///引用“节点/节点”
Nothing happens...
什么也没发生……
But this does work, VS Code is responding. (Edit: stops the warning, but no auto-completion this way):
但这确实有效,VS代码正在响应。(编辑:停止警告,但不自动完成):
Mark '__dirname' as global
马克__dirname随着全球
#1
24
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.
TSD是TypeScript定义,而TypeScript则是由Microsoft编译成普通JavaScript的一组类型的JavaScript。如果您只是想使用VSCode来开发通用的基于javascript的节点,那么您不需要理解这些。js项目喜欢我。
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.
为了解决您的问题,我认为更好的方法是将TSD包管理器安装为一个全局模块。这将使您能够使用全局命令tsd。
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'.
这将自动创建一个名为“node.d”的文件夹“typings/node”。
If you also need IntelliSense for third party modules like express.js or async.js, you can just add them by yourself
如果你还需要像express这样的第三方模块的智能感知。js或异步。js,你可以自己添加。
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)
您已经熟悉的“npm”是node的包管理器。js,“tsd”是TypeScript定义的包管理器(但不是针对TypeScript本身)
There's a list here showing the available repositories.
这里有一个显示可用存储库的列表。
http://definitelytyped.org/tsd/
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.
一旦您将所有的.tsd文件下载到“typings”文件夹中,您仍然需要在每个.js文件的开头手动放置这些特殊的注释,以帮助VSCode查找node和express的定义,所以现在VSCode知道类和函数的API细节。
/// <reference path="typings/node/node.d.ts"/>
/// <reference path="typings/express/express.d.ts"/>
#2
2
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.
你不应该把参考书放在自己的位置上。你应该通过按下“Ctrl + .”(你应该按下的点键)来为你做,在标记的__dirname上,并选择在网站上说的TypeScript定义文件的选项。
VS Code will create the directories structure under your project folder, download the file and add the reference to your app.js express application.
VS代码将在您的项目文件夹下创建目录结构,下载该文件并将引用添加到app.js express应用程序中。
#3
0
I had the same problem with angular and this is how I got it to work for me: It looks like the problem was that VSCode failed to download the file and create the directories. I googled angular.d.ts and found it on GitHub - DefinitelyTyped
我有同样的角度问题,这是我如何让它为我工作的:看起来问题是,VSCode没有下载文件并创建目录。我用谷歌搜索了angular.d。ts并在GitHub上找到它。
I created "typings/angularj/" folders and added the file and now intellisense is working for angular :)
我创建了“typings/angularj/”文件夹,并添加了文件,现在intellisense正在为棱角而工作:)
So just grab the "node.d.ts" file instead of from DefinitelyTyped and it should work for you as well.
所以只要抓住“node.d”。“文件”而不是“定义式”,它也应该为你工作。
#4
0
As @HenryLi mentioned, you need to get a file with type definitions for Node. However TSD has been deprecated for quite a while now. Worry not, however! Now the type definitions are managed directly by Microsoft and bundled right through npm
!
正如@HenryLi所提到的,您需要获取一个带有节点类型定义的文件。然而,TSD已经被弃用已经有一段时间了。但是,别担心!现在,类型定义由Microsoft直接管理,并将其绑定到npm!
To solve your problem, it's enough to run this command:
要解决您的问题,可以运行以下命令:
npm install --save -g @types/node
#5
-2
(Edit: VS Code needs me to open a directory, and not a single file to let intellisense work well)
(编辑:VS代码需要我打开一个目录,而不是一个文件让智能感知工作正常)
Same problem for me.
对我同样的问题。
This does not work:
这并不工作:
Add /// reference to 'node/node.d.ts'
添加///引用“节点/节点”
Nothing happens...
什么也没发生……
But this does work, VS Code is responding. (Edit: stops the warning, but no auto-completion this way):
但这确实有效,VS代码正在响应。(编辑:停止警告,但不自动完成):
Mark '__dirname' as global
马克__dirname随着全球