相关疑难解决方法(0)

Angular和Typescript:找不到名字

我正在使用带有TypeScript(版本1.6)的Angular(版本2),当我编译代码时,我得到以下错误:

Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(1,25): Error TS2304: Cannot find name 'MapConstructor'.
    node_modules/angular2/src/core/facade/collection.d.ts(2,25): Error TS2304: Cannot find name 'SetConstructor'.
    node_modules/angular2/src/core/facade/collection.d.ts(4,27): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(4,39): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(7,9): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(8,30): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(11,43): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(12,27): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(14,23): Error TS2304: Cannot find name 'Map'.
    node_modules/angular2/src/core/facade/collection.d.ts(15,25): Error TS2304: …
Run Code Online (Sandbox Code Playgroud)

typescript angular

215
推荐指数
12
解决办法
25万
查看次数

Angular 2 beta.17:'Observable <Response>'类型中不存在属性'map'

我刚刚从Angular 2 beta16升级到beta17,后者又需要rxjs 5.0.0-beta.6.(更改日志:https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta17-2016-04-28)在beta16中,所有关于Observable/map功能的都很好.升级后出现以下错误,当typescript尝试转换时出现:

  1. 类型'Observable'上不存在属性'map'(我在地图中使用了带有observable的地图)
  2. c:/path/node_modules/rxjs/add/operator/map.d.ts(216):error TS2435:Ambient模块不能嵌套在其他模块或名称空间中.
  3. c:/path/node_modules/rxjs/add/operator/map.d.ts(2,16):错误TS2436:环境模块声明无法指定相对模块名称.

我已经看到了这个问题/答案,但它没有解决问题: Angular2 beta.12和RxJs 5 beta.3的可观察错误

我的appBoot.ts看起来像这样(我已经引用了rxjs/map):

///<reference path="./../node_modules/angular2/typings/browser.d.ts"/>
import {bootstrap} from "angular2/platform/browser";
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
[stuff]
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import {enableProdMode} from 'angular2/core';
import { Title } from 'angular2/platform/browser';


//enableProdMode();
bootstrap(AppDesktopComponent, [
    ROUTER_PROVIDERS,
    HTTP_PROVIDERS,
    Title
]);
Run Code Online (Sandbox Code Playgroud)

有人知道发生了什么事吗?

rxjs typescript angular

192
推荐指数
15
解决办法
18万
查看次数

Angular Cli Webpack,如何添加或捆绑外部js文件?

在将Angular Cli从SystemJs切换到Webpack之后,我不确定如何包含JS文件(供应商).

例如

选项A.

我有一些通过npm安装的js文件.像这样在head标签中添加脚本标签不起作用.它似乎也不是最好的方式.

<head>
   <script src="node_modules/some_package/somejs.js">
</head>

//With systemJs I could do this

<head>
   <script src="vendor/some_package/somejs.js">
</head>
Run Code Online (Sandbox Code Playgroud)

选项B.

将这些js文件包含在webpack包中.这似乎应该是它应该做的方式.但是我不知道如何做到这一点,因为所有的webpack代码似乎都隐藏在angular-cli-webpack节点包之后.我想也许还有另一个我们可以访问的webpack配置.但我不确定,因为在创建一个新的angular-cli-webpack项目时我没有看到.

更多信息:

我想要包含的js文件需要包含在Angular项目之前.例如jQuery和第三方js lib,它实际上没有为模块加载或打字稿设置.

参考 https://github.com/angular/angular-cli/blob/master/WEBPACK_UPDATE.md https://github.com/angular/angular-cli/tree/webpack

javascript angular-cli angular

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

错误TS2304:找不到名字'承诺'

大家好,我在stackoverflow上经历了所有解决方案.但对我来说没有任何工作.因此发布问题. tsconfig.json

{
  "version":"2.13.0",
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": false    
  },
  "exclude": [
        "node_modules"
    ]
}
Run Code Online (Sandbox Code Playgroud)

的package.json

{
  "name": "anguapp",
  "version": "1.0.0",
  "description": "Angular2 Gulp Typescript and Express",
  "main": "dist/server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "gulp build"
  },
  "keywords": [],
  "author": "UK",
  "license": "MIT",
  "dependencies": {
    "angular2": "2.0.0-beta.17",
     "es6-promise": "3.2.1",
    "es6-shim": "0.35.1",
    "body-parser":"1.15.2",
    "express": "4.13.3",
    "gulp-concat": "2.6.0",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.37", …
Run Code Online (Sandbox Code Playgroud)

node.js typescript angular

15
推荐指数
1
解决办法
1万
查看次数

WebStorm 2016.3错误:对装饰器的实验性支持是一个在将来的版本中可能会发生变化的功能

嗨更新到最新的WebStorm,我现在收到此错误:

Error:(52, 14) TS1219:Experimental support for decorators 
is a feature that is subject to change in a future release. 
Set the 'experimentalDecorators' option to remove this warning.
Run Code Online (Sandbox Code Playgroud)

但在我的tsConfig experimentalDecorators中设置为true:

{
  "version": "1.5.0",
  "compilerOptions": {
    //...,
    "experimentalDecorators": true,   // <======== HERE
    //...,
  },
  "files": [
    //...
  ],
  "exclude": [ "node_modules" ]
}
Run Code Online (Sandbox Code Playgroud)

phpstorm webstorm meteor typescript angular

12
推荐指数
3
解决办法
9416
查看次数

构建:找不到名称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万
查看次数

Angular2构建错误 - 找不到类型

我在打字方面遇到了一些问题.当我运行时,npm start我得到以下错误:

> tsc && concurrently "npm run tscw" "npm run lite"

node_modules/@angular/common/src/directives/ng_class.d.ts(72,35): error TS2304: Cannot find name 'Set'.
node_modules/@angular/common/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/common/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/common/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'.
node_modules/@angular/common/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(10,35): error TS2304: …
Run Code Online (Sandbox Code Playgroud)

node.js angularjs typescript angular

6
推荐指数
1
解决办法
8096
查看次数