Angular 2 2.0.0-rc.1 속성 'map'이 'Observable 유형에 존재하지 않습니다.'문제 보고서와 동일하지 않음
Angular 2 beta.17 과 동일한 문제로 보이지만 'Observable <Response>'유형에 'map'속성이 없습니다.
이것은 새 버전이며 해당 솔루션은이 새로 출시 된 버전에서 작동하지 않습니다.
최신 Angular 2 rc1로 업데이트했는데 컴파일 할 수 없습니다. 'Promise'를 인식하지 못하는 문제가 있었는데 결국 es6-promise 타이핑을 직접 설치하여 문제를 해결했습니다. 다양한 수입 명세서를 입력하려고 시도했지만 운이 없습니다. 저는 Visual Studio 2015에서 실행 중입니다.
import 'rxjs/Rx';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/map';
return this._http.post(url, null, args).map(extractData).toPromise();
하지만 계속해서 속성 'map'이 'Observable'유형에 존재하지 않습니다.
내 패키지 파일은
"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",
"systemjs": "0.19.27",
"es6-shim": "^0.35.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"bootstrap": "^3.3.6",
"breeze-client": "~1.5.6",
"handlebars": "^4.0.5"
},
"devDependencies": {
"typescript": "^1.8.10",
"typings": "^0.8.1",
"gulp": "^3.9.1",
"jasmine-core": "~2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-coverage": "^0.5.5",
"remap-istanbul": "^0.6.3",
"karma-jasmine": "^0.3.8",
"karma-jasmine-html-reporter": "^0.2.0",
"http-server": "^0.9.0"
}
이 가져 오기를 시도 했습니까? 그것은 나를 위해 작동합니다
import {Observable} from 'rxjs/Rx';
import 'rxjs/add/operator/map';
해결 방법은 다음과 같습니다. jjokela와 VahidN은 그들의 의견과 함께 그것을 암시했다. 여기에 있는 Deborah Kurata의 블로그 게시물을보고 찾았습니다 . 그녀는 내가 사용하는 새로운 ASP.NET 5 RC 템플릿이 아닌 ASP.NET 4 프로젝트 템플릿과 함께 Angular2를 사용하는 방법을 설명합니다.
수정하려면 https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-229506507에있는 이 지침을 참조하세요.
이 수정은 Visual Studio 용 Typescript 2.0 릴리스에 포함될 예정입니다. 아래의 수동 단계를 수행 할 수있을 때까지.
VS 2015 (업데이트 3) :
VS 2015 업데이트 3 설치 C : \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TypeScript \ typescriptServices.js를 https://raw.githubusercontent.com/Microsoft/TypeScript 의 파일로 바꿉니다. /Fix8518-U3/lib/typescriptServices.js . 먼저 로컬 백업을 수행하십시오.
VS 2015 (업데이트 2) :
VS 2015 업데이트 2 설치 C : \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TypeScript \ typescriptServices.js를 https://raw.githubusercontent.com/Microsoft/TypeScript 의 파일로 바꿉니다. /Fix8518/lib/typescriptServices.js . 먼저 로컬 백업을 수행하십시오.
VS 2013의 경우 :
TypeScript 1.8.5 설치 ( https://www.microsoft.com/en-us/download/details.aspx?id=48739 ) C : \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ Common7 \ IDE \ CommonExtensions 교체 \ Microsoft \ TypeScript \ typescriptServices.js와 https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js에 있는 파일 . 먼저 로컬 백업을 수행하십시오.
나는 같은 문제를 겪고 있었다. 이 줄을 AppComponent 클래스에 추가 한 후 해결 된 것 같습니다.
import 'rxjs/Rx';
제외하고 아무것도
import { Observable } from 'rxjs/Rx';
이 문제는 아직 전체 VS 릴리스를 보지 못한 https://github.com/Microsoft/TypeScript/issues/7415 와 관련이있을 가능성이 높습니다 . 소스를 로컬로 빌드하고 VS Dev Mode를 사용할 수 있습니다 .
Angular2 RC로 업그레이드 한 후에도 동일한 문제가 발생합니다. 속성 'map'에 대한 VS 2015 Intellisense 오류가 'Observable'유형에 존재하지 않습니다.
저는 grunt-ts를 사용하여 트랜스 파일을 수행하므로 트랜스 파일 능력에 영향을 미치지는 않지만 이전에 없었던 오류로 편집기에서 보는 것은 귀찮습니다.
문제가 Visual Studio 용 Typescript 다운로드에 있다고 생각합니다. https://www.microsoft.com/en-us/download/details.aspx?id=48593
현재 버전 1.8.6이며 Visual Studio의 지능을 주도하고 구성하는 경우 typescript 컴파일에서 빌드한다고 생각합니다. 따라서 Visual Studio에서 새 버전의 Typescript가 삭제 될 때까지 기다려야 할 수도 있습니다.
Dan-Angular 2 rc1로 업그레이드 한 후 Observable을 코드에 추가하자마자 성공적인 실행을 위해 일련의 문제가 발생했습니다. 나를 위해 수정 한 것은 추가하는 것입니다.
"emitDecoratorMetadata": true,
내 tsconfig.json 파일에. 그 줄을 추가하면 IIS와 npm start를 사용하여 올바르게 렌더링되었습니다. 내 전체 tsconfig.json 파일은 다음과 같습니다.
{"compilerOptions": {
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true }, "exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts" ]}
(포맷에 대해 죄송합니다 ... 늦었습니다). 도움이 되었기를 바랍니다.
toPromise.d.ts에서
add "import {Observable} from '../../Observable';"
import { ToPromiseSignature } from '../../operator/toPromise';
import {Observable} from '../../Observable';
declare module '../../Observable' {
interface Observable<T> {
toPromise: ToPromiseSignature<T>;
}
}
map.d.ts에 대해서도 똑같이 할 수 있습니다.
도움이 되었기를 바랍니다.
수입품이 좋습니다. 문제의 근본 원인은 https://github.com/ReactiveX/rxjs/issues/1540에 설명되어 있습니다.
이 문제를 해결하려면 최신 typescript 1.8로 업그레이드해야합니다.
Please note that that when you run tsc
you are using global typescript (check tsc -v
) To upgrade global typescript, run npm i typescript -g
.
If you want to use typescript defined in package.json
, you need to execute it via "scripts"
, i.e. add "build": "tsc"
and execute it with npm run build
.
I am having the same issue. I'm running TypeScript 1.8.11. I have no solution I'm afraid. I think it is a genuine issue with either rxjs or angular 2 rc 1.
I downgraded rxjs to beta 2 and it fixed that issue. Unfortunately angular rc1 depends on beta 6 so doing a full npm install fails.
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions} from '@angular/http';
import 'rxjs/Rx';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
return this._http.post(url, null, args).map(this.extractData)
Make Function extractData
Try this one .It will work for you. It is working for me.
i got this working for ag-grid angular 2's component which is here.
i needed the typings for Promise which you get with: tsd install es6-shim
then in your typescript options, specify the downloaded typings file like as one of the files to compile in tsconfig.json, ie:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "lib"
},
"files": [
"typings/es6-shim/es6-shim.d.ts", // the typings file
"app/boot.ts" // you application
]
}
Installing the typings for es6-shim
resolved the same issue for me:
typings i es6-shim --ambient --save-dev
It was a breaking change in beta 6 and to get round it you could include a reference to the internal typings files inside angular. Unfortunately these have been removed in 2.0.0-rc.0 so you must rely on the external typings for the same thing now.
if you've just upgraded to Angular2 rc1, make sure you're using the new @angular import statements, rather than the angular2:
`import { Component } from 'angular2/core';`
becomes,
`import { Component } from '@angular/core';`
I know it seems simple, but it can cause this issue.
Find beta release 2.0.0 of TypeScript for Visual Studio 2015. This release solved same issue on my machine. But remember, it's a beta.
If you are upgrading from an Angular2 release-candidate ( i.e. 2.0.0-rc.1 ) to a 2.x.x release, you'll want to:
Update your package.json to be up-to-date with the file at https://github.com/angular/quickstart/blob/master/package.json
Update your systemjs.config.js file to be up-to-date with the file at https://github.com/angular/quickstart/blob/master/systemjs.config.js
Change the import statement to:
import {Observable} from 'rxjs'
'Development Tip' 카테고리의 다른 글
C의 구조 상속 (0) | 2020.11.29 |
---|---|
System.Collections.Generic.List에 'Select'에 대한 정의가 없습니다. (0) | 2020.11.29 |
JSON을 사용하여 XmlHttpRequest POST 만들기 (0) | 2020.11.29 |
WPF에서 Button FlatStyle 설정 (0) | 2020.11.29 |
* .tar.gz가 여전히 * .tar.xz보다 훨씬 더 일반적인 이유는 무엇입니까? (0) | 2020.11.29 |