打印稿Angular2输入d。在Visual Studio代码中。

时间:2021-10-23 15:13:21

Quite possible that I am really missing something. But for the life of me I can not get typings to work for Typescript + Angular2. Not with /// per file nor for the entire workspace. I have tried manually grabbing the source of angular2 off github and putting in a /typings directory within the workspace. I have tried using tsc to install angular2 typings I have tried the tsd.json file that Badal in this Stack Overflow thread was nice enough to post. But no matter what Vscode continues to say Cannot find module <blerg> (ie. angular2/core, angular2/common, etc...) And its driving me nuts!

很可能我真的漏掉了什么。但是对于我的生活来说,我不能为打字稿和Angular2打字。不是用///每个文件,也不是整个工作空间。我尝试过手动抓取angular2的源代码,并在工作区中放入/typings目录。我已经试过用tsc来安装angular2的类型,我尝试过tsd。在这个堆栈溢出线程中Badal的json文件非常好,可以发布。但是无论Vscode继续说什么都找不到模块 (ie)。angular2 /核心,angular2 /常见等…)它快把我逼疯了!

Any help would be GREATLY appreciated!

非常感谢您的帮助!

2 个解决方案

#1


3  

I don't think there is already an extension for installing .td directly from VS CODE. Besides that the Angular definitions are shipped with the Angular2 package from npm:

我不认为现在已经有了直接从VS代码安装.td的扩展。除此之外,角的定义与npm的Angular2包一起发货:

npm install angular2

The npm package already gives you the definitions. You need to configure your Typescript with:

npm包已经提供了定义。您需要配置您的Typescript:

--moduleResolution node

#2


1  

But no matter what Vscode continues to say Cannot find module

但是无论Vscode怎么说都找不到模块。

You probably forgot to restart vscode after following the basic guide.

您可能忘记了在遵循基本指南之后重新启动vscode。

npm install angular2
tsc -init
code .

#1


3  

I don't think there is already an extension for installing .td directly from VS CODE. Besides that the Angular definitions are shipped with the Angular2 package from npm:

我不认为现在已经有了直接从VS代码安装.td的扩展。除此之外,角的定义与npm的Angular2包一起发货:

npm install angular2

The npm package already gives you the definitions. You need to configure your Typescript with:

npm包已经提供了定义。您需要配置您的Typescript:

--moduleResolution node

#2


1  

But no matter what Vscode continues to say Cannot find module

但是无论Vscode怎么说都找不到模块。

You probably forgot to restart vscode after following the basic guide.

您可能忘记了在遵循基本指南之后重新启动vscode。

npm install angular2
tsc -init
code .