Visual Studio 2015中用于Angular2的TypeScript IntelliSense

时间:2016-06-06 10:29:09

标签: typescript angular

我使用" ASP.NET核心Web应用程序(.NET Core)"创建了一个项目。空项目模板。我在https://angular.io/guide/quickstart做了Angular2快速入门教程。这一切都很好,我已经启动了快速入门项目。

问题是现在我开始添加自己的TypeScript文件,Angular2的intellisense似乎不起作用。

我安装了TypeScript 1.8.10。

我在 package.json 中使用@ angular / dependencies,如下所示;

{
  "name": "product-management",
  "version": "1.0.0",
  "author": "Deborah Kurata",
  "description": "Package for the Acme Product Management sample application",
  "scripts": {
    "start": "concurrently \"npm run tsc:w\" ",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "postinstall": "typings install",
    "gulp": "gulp"

  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.1",
    "@angular/compiler": "2.0.0-rc.1",
    "@angular/core": "2.0.0-rc.1",
    "@angular/http": "2.0.0-rc.1",
    "@angular/platform-browser": "2.0.0-rc.1",
    "@angular/platform-browser-dynamic": "2.0.0-rc.1",
    "@angular/router": "2.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.1",
    "@angular/upgrade": "2.0.0-rc.1",

    "systemjs": "0.19.29",
    "core-js": "2.4.0",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "0.6.12",

    "angular2-in-memory-web-api": "0.0.11",
    "bootstrap": "3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "typescript": "^1.8.10",
    "typings": "1.0.4",
    "gulp": "3.9.1",
    "gulp-clean": "0.3.2"
  },
  "repository": { }
}

这是我的 tsconfig.json 文件;

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "noEmitOnError": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  },
  "compileOnSave": true
}

我的typings.json文件;

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160317120654",
    "jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
    "node": "registry:dt/node#4.0.0+20160509154515"
  }
}

在我项目的根目录下自动创建了typings文件夹,其中包含上述库类型的文件夹。

这是我的项目结构;

project_structure

当我查看" node_modules / @ angular /"文件夹,我可以看到它们包含TypeScript定义的* .d.ts文件,但是你可以看到这个文件夹不是"包含"在我的项目中,所以我不确定Visual Studio是否正在使用.d.ts文件......?

我一直在寻找答案,但很多帖子都不是基于使用Visual Studio 2015而且还使用了#34; angular2"而不是更新的" @ angular"依赖结构。

在Visual Studio 2015中,是否有人能指出我正确的检查/配置方向以使TypeScript intellisense与Angular2一起使用。

最后,当我说它不起作用时,如果我添加一个文件,例如" file.ts"然后尝试键入类似@Component(应该击中Angular2 intellisense)的东西,它不会,而是建议使用"组件"英寸

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

我意识到我的intellisense问题与我编写打字稿文件的顺序一致...(非常尴尬)。

当我首先在顶部写入import语句时,即

import { Component } from "@angular/core"

然后开始写下角,intellisense工作正常..

@Component({

})

export class AppComponent {
    pageTitle: string = "Acme Product Management";
}
相关问题