问题描述
我不知道我知道智能手机如何适用于微软新的vsCode文本编辑器。在伟大的代码编辑体验标题下的文件(d.ts)直接(没有编辑器建议),或者是否必须从github源中复制它们,并将它们放在打字目录中?
2 - 我可以获得任何具有类型说明定义的库的智能感知?我尝试下面的,但是当我输入 express。
或 when。
,我没有任何智能感知。但是,我得到节点智能感知。
///< reference path =../ typings / node / node.d.ts/>
///< reference path =../ typings / express / express.d.ts/>
var when = require('when')
,express = require('express')
,gulp = require('gulp')
更新:2016年8月:TSD现已折旧。而是使用
npm安装打字--global
OR
如果在2016年7月29日发布使用VS2015 NodeJS v1.2,则首次使用时会自动为您安装[email protected] :
执行命令'npm installC:\PROGRAM FILES(X86)\MICROSOFT VISUAL STUDIO 14.0 \COMMON7 \\ $ \\ \\ \\ \\ \\ \\ \\ \\ \\\\\
ode_modules\\\
tvs-typings-acquisition-tool
├──[email protected]
└──[email protected](array-uniq @ 1.0.3,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],xtend @ 4.0.1,[email protected],[email protected],lockfile @ 1.0.1,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]。 1,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],touch @ 1.0.0,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected])
-----原始答案-----
有一个包描述文件的包管理器。这是一个社区驱动的存储库,它包含许多受欢迎的库的Typescript定义。
您可以按照说明安装tsd =noreferrer>
全局安装tsd后,您可以在命令行中安装项目根目录中的软件包,如这个:
$ tsd install express --save
如果不存在,将创建一个打字目录,并添加一个具有 express.d.ts
文件的快速目录
它还创建一个 tsd.d.ts
文件,其中包含对所有tsd文件的引用。如果我安装了更多的tsd,这是它的样子。
现在,要访问我的tsd文件,我所需要做的就是使用 ///< reference path =typings / tsd.d.ts/>
现在我得到智能感知。
I'm not sure I understand how the intellisense works for Microsoft's new vsCode text editor. In the docs under the "Great Code Editing Experience" heading, it shows a warning under the node global variable __dir
and offers a lightbulb suggestion to add a reference to a d.ts file so you can get intellisense for node:
I have 2 questions:
1 - How do I import DefinitelyTyped files (d.ts) directly (without editor suggesting it) or do I have to copy them from the github source and put them in a typings directory?
2 - Can I get intellisense for any library that has a typescript definition? I tried the below, but when I type in express.
or when.
, I don't get any intellisense. However, I do get node intellisense.
/// <reference path="../typings/node/node.d.ts"/>
/// <reference path="../typings/express/express.d.ts" />
var when = require('when')
, express = require('express')
, gulp = require('gulp')
UPDATE: August 2016: TSD is now depreciated. instead usehttps://www.npmjs.com/package/typings
npm install typings --global
OR
If using VS2015 NodeJS v1.2 released 29th July 2016 then [email protected] is installed automatically for you during first use:
Executing command 'npm install "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\MICROSOFT\NODE.JS TOOLS FOR VISUAL STUDIO\1.2\TypingsAcquisitionTool"
[email protected] ..\..\..\..\..\node_modules\ntvs-typings-acquisition-tool
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
-----Original Answer-----
There is a package manager for Typescript Definition Files. This is a community driven repository containing Typescript definitions for many popular libraries.
You can install tsd by following the instructions here.
Once you install tsd globally, you can install packages from your project root in the command line like this:
$ tsd install express --save
This will create a typings directory if one doesn't exist and adds an express directory with an express.d.ts
file inside.
It also creates a tsd.d.ts
file that contains the references to all of your tsd files. If I install a few more tsd's, here is what it looks like.
Now to access my tsd files, all I need to do is reference their path in at the top of my code with /// <reference path="typings/tsd.d.ts" />
Now I get intellisense.
这篇关于如何将Intellisense文件导入vsCode(Visual Studio代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!