enter image description here

这些红色的曲线表示cannot find module 'angular2/core'cannot find module 'angular2/router'cannot find module 'angular2/http'.

我还添加了对d.ts个文件的引用,如下所示,但仍然不起作用.

其他帖子说我需要在tsconfig.json文件中配置一些东西,但我使用的是Visual Studio,我认为没有必要使用angular团队建议的tscompiler,因为Visual Studio应该能够自动编译ts文件.

我错过什么了吗?

Is the 100 still required even if you use Visual Studio?

How do I get rid of these squiggly lines?

谢谢!

(我正在使用Visual Studio 2015和最新的Typescript引擎)

更新: 我不确定NPM包管理器到底是什么.但是我有一个预先构建的package.json文件,它是在创建项目时创建的.我使用此文件安装NPM包. enter image description here

推荐答案

对于VS2015中的ASP.NET5.0应用程序来说,配置TypeScript有点困难.

在围绕typescript的工具改进之前,您可以手动配置typescript:

Step 1: Right-click project, and Unload Project 
Step 2: Right-click the unloaded project, and Edit the .xproj file
Step 3: Add a PropertyGroup node, under the Project node:

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptJSXEmit>None</TypeScriptJSXEmit>
    <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
    <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
    <TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
    <TypeScriptRemoveComments>False</TypeScriptRemoveComments>
    <TypeScriptOutFile />
    <TypeScriptOutDir />
    <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
    <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
    <TypeScriptSourceMap>True</TypeScriptSourceMap>
    <TypeScriptMapRoot />
    <TypeScriptSourceRoot />
    <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
  </PropertyGroup>

Step 4: Right-click the unloaded project and Reload Project
Step 5: Re-build project

如果仍然遇到找不到模块的错误,请退出visual studio并重新加载解决方案.

Angular相关问答推荐

Angular独立组件(使用LoadComponents)-懒惰加载服务不工作

如何在Angular 17中使用Angular—calendum?

Ionic 5角形共享两个模块之间的组件

存储服务存储在本地存储中,但无法检索到它

Angular:将服务注入非独立组件导致应用程序中断

在Angular 为17的独立零部件中使用@NGX-平移

如何使用formBuilder.Group()从角形表单中删除选定的选项?

元素上的Angular 管道链接不起作用

如何检测 Angular Universal 预渲染版本?

MAT折叠面板的动态开启和关闭无法工作

ng 生成组件不会创建 ngOnInit 和构造函数

Angular 13 - 何时创建嵌入式视图?

关闭 Dynamsoft Web Twain 弹出窗口

取消订阅服务中的http observable

如何在angular 5 中获取基本网址?

Angular 5 Mat-grid 列表响应式

Angular 5 响应式表单 - 单选按钮组

angular 5 material - 表单字段停留在 180px

Lint 错误:实现生命周期挂钩接口

如何防止角material垫菜单关闭?