5

# Đây là lỗi tôi đang phải đối mặt hiện nay:Class 'Chủ đề <T>' không đúng cách mở rộng lớp cơ sở 'Quan sát <T> Nativescript navigation ngăn lỗi

i tải mẫu ngăn kéo chuyển hướng sử dụng NPM (https://github.com/shripalsoni04/nativescript-angular-drawer-template). nhưng nó đưa ra lỗi sau.

[email protected]:~/NativeApp/Supervisor$ tns run android 

Searching for devices... 
iTunes is not available for this operating system. You will not be able to work with connected iOS devices. 
Executing before-prepare hook from /home/dhrn/NativeApp/Supervisor/hooks/before-prepare/nativescript-dev-typescript.js 
Found peer TypeScript 2.4.1 
node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'. 
    Types of property 'lift' are incompatible. 
    Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'. 
     Type 'Observable<T>' is not assignable to type 'Observable<R>'. 
     Type 'T' is not assignable to type 'R'. 

node_modules/tns-core-modules/ui/core/properties/properties.d.ts(48,14): error TS2559: Type 'Property<T, U>' has no properties in common with type 'TypedPropertyDescriptor<U>'. 

node_modules/tns-core-modules/ui/core/properties/properties.d.ts(59,14): error TS2559: Type 'CoercibleProperty<T, U>' has no properties in common with type 'TypedPropertyDescriptor<U>'. 

Unable to apply changes on device: 192.168.56.101:5555. Error is: TypeScript compiler failed with exit code 1. 


``` 
**My configuration:** 

``` 
{ 
    "description": "NativeScript Application", 
    "license": "SEE LICENSE IN <your-license-filename>", 
    "readme": "NativeScript Application", 
    "repository": "<fill-your-repository-here>", 
    "nativescript": { 
     "id": "org.nativescript.supervisor", 
     "tns-android": { 
      "version": "3.1.1" 
     } 
    }, 
    "dependencies": { 
     "@angular/common": "~4.0.0", 
     "@angular/compiler": "~4.0.0", 
     "@angular/core": "~4.0.0", 
     "@angular/forms": "~4.0.0", 
     "@angular/http": "~4.0.0", 
     "@angular/platform-browser": "~4.0.0", 
     "@angular/platform-browser-dynamic": "~4.0.0", 
     "@angular/router": "~4.0.0", 
     "nativescript-angular": "~3.0.0", 
     "nativescript-telerik-ui": "^2.0.1", 
     "nativescript-theme-core": "~1.0.4", 
     "reflect-metadata": "~0.1.8", 
     "rxjs": "~5.2.0", 
     "tns-core-modules": "~3.0.0", 
     "zone.js": "0.8.2" 
    }, 
    "devDependencies": { 
     "babel-traverse": "6.18.0", 
     "babel-types": "6.18.0", 
     "babylon": "6.13.1", 
     "lazy": "1.0.11", 
     "nativescript-dev-typescript": "^0.4.0", 
     "typescript": "^2.3.2", 
     "zone.js": "~0.7.2" 
    } 
} 

Cấu hình dự án:

[email protected]:~/NativeApp/Supervisor$ tns info 
All NativeScript components versions information 
┌──────────────────┬─────────────────┬────────────────┬───────────────┐ 
│ Component  │ Current version │ Latest version │ Information │ 
│ nativescript  │ 3.1.1   │ 3.1.1   │ Up to date │ 
│ tns-core-modules │ 3.1.0   │ 3.1.0   │ Up to date │ 
│ tns-android  │ 3.1.1   │ 3.1.1   │ Up to date │ 
│ tns-ios   │     │ 3.1.0   │ Not installed │ 
└──────────────────┴─────────────────┴────────────────┴───────────────┘ 

Xin vui lòng giúp tôi khắc phục vấn đề này.

+0

Bản sao có thể có của [Làm thế nào để giải quyết vấn đề này "Chủ đề không chính xác mở rộng Observab le "lỗi trong TypeScript 2.4 và RxJS 5.x?] (https://stackoverflow.com/questions/44810195/how-do-i-get-around-this-subject-incorrectly-extends-observable-error-in- loại) –

+0

Trông giống như một bản sao của https://stackoverflow.com/questions/44810195/how-do-i-get-around-this-subject-incorrectly-extends-observable-error-in-types. Bạn có thể giải quyết vấn đề này với tùy chọn trình biên dịch 'noStrictGenericChecks'. –

Trả lời

12

Có một số cập nhật issues with Microsoft/Typescript 2.4.1.
Từ các cuộc thảo luận ở trang vấn đề này, có vẻ như bạn cần phải sử dụng

enter image description here
cấu hình. Đảm bảo rằng bạn thực sự đã cài đặt typescript 2.4.0.
Bạn có thể tải nó từ here

+0

Tôi cần sử dụng loại 2,3.4 – jim

+0

@jim trong trường hợp đó đảm bảo rằng bạn có nó là "" bản ghi "": "2.3.4" không phải là "" kiểu chữ ":"^2.3.4 "' hoặc '" kiểu chữ ":" ~ 2.3.4 "', Tham khảo [tại đây] (https://github.com/Microsoft/TypeScript/issues/16593) và một lần nữa bạn _should_ có phiên bản cụ thể này được cài đặt – Irfan

+0

Tôi đang gặp phải lỗi mới - > node_modules/tns-core-modules/ui/core/properties/properties.d.ts (48,14): lỗi TS2559: Loại 'Thuộc tính ' không có thuộc tính chung với loại 'TypedPropertyDescriptor '. node_modules/tns-core-modules/ui/core/properties/properties.d.ts (59,14): lỗi TS2559: Loại 'CoercibleProperty ' không có thuộc tính chung với loại 'TypedPropertyDescriptor '. –

1

thử tsconfig.json này

RxJS 6 sẽ có điều này cố định, nhưng như một cách giải quyết tạm thời, bạn có thể sử dụng tùy chọn noStrictGenericChecks biên dịch

"noStrictGenericChecks" : true

{ 
    "compileOnSave": true, 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ "es2015", "dom" ], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true, 
    "noStrictGenericChecks": true 
    } 
} 
Các vấn đề liên quan