相关疑难解决方法(0)

得到错误 - 找不到名字'angular'

我开始使用TypeScript编写AngularJS应用程序.我有这个简单的模块命令:

(() => {
    angular
        .module('app', []);
})();
Run Code Online (Sandbox Code Playgroud)

当我跑步时tsc app.ts,我得到了这个:app.ts(2,5): error TS2304: Cannot find name 'angular'.

我需要包括的东西app.ts,使tsc理解angular

问候,

angularjs typescript

27
推荐指数
3
解决办法
4万
查看次数

构建:找不到名称Promise - Visual Studio 2015 w/MVC6和Angular 2

首先:我检查过这些:

https://github.com/angular/angular/issues/7052

https://github.com/angular/angular/issues/4902

尽管使用ECMAScript 6,却打字稿找不到名字'Promise'

如何使用打字稿的es6-promises?

Visual Studio代码:找不到名字角?

如何摆脱Angular2/TypeScript错误无法找到地图,承诺...当定位-es5时

还有很多很多.现在已经敲了两天头.

是的:

我在我的boot.ts文件(或引导程序文件)中引用了:

///<reference path="../node_modules/angular2/typings/browser.d.ts"/> 
Run Code Online (Sandbox Code Playgroud)

现在,问题是:我正在使用Visual Studio 2015 W/Update 1和ASP.NET MVC 6项目(Release Candidate 1)+ Typescript 1.8.1.

我使用本教程进行设置:http: //www.mithunvp.com/angular-2-in-asp-net-5-typescript-visual-studio-2015/

我已经成功使用Angular 2了一段时间,现在相同的代码(afaik)将无法编译.它将在browser.dmles/angular2/platform中找到"在browser.d.ts文件中找不到名称:Promise""

tsconfig.json

 {
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "../wwwroot/appScripts/",
    "removeComments": false,
    "sourceMap": true,
    "target": "es5"
  },
  "exclude": [
    "node_modules"
  ]
}
Run Code Online (Sandbox Code Playgroud)

的package.json

{
    "version": "1.0.0",
    "name": "asp.net", 
  "private": true,
  "dependencies": {
    "angular2": "2.0.0-beta.11",
    "systemjs": "0.19.24",
    "es6-promise": "^3.1.2",
    "es6-shim": "^0.35.0",
    "reflect-metadata": "0.1.2",
    "rxjs": …
Run Code Online (Sandbox Code Playgroud)

typescript asp.net-core-mvc visual-studio-2015 angular

8
推荐指数
2
解决办法
2万
查看次数