VS 2017和ASP.NET MVC Subject.d.ts文件的角度错误

问题描述 投票:0回答:1

我正在学习在VS 2017中创建一个Angular 2项目,并且它在构建过程中出现以下错误:

Error       Build:Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.    Angular2MVC D:\myProjects\Angular2MVC\Angular2MVC\Angular2MVC\node_modules\rxjs\Subject.d.ts    16  

    Severity    Code    Description Project File    Line    Suppression State
Error   TS2415  (TS) Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
    Type '<T, 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'. Angular2MVC (tsconfig project)  D:\myProjects\Angular2MVC\Angular2MVC\Angular2MVC\node_modules\rxjs\Subject.d.ts    16  Active

以下是Subject.d.ts文件中的行:

    export declare class Subject<T> extends Observable<T> implements ISubscription {
    observers: Observer<T>[];
    closed: boolean;
    isStopped: boolean;
    hasError: boolean;
    thrownError: any;
    constructor();
    static create: Function;
    lift<T, R>(operator: Operator<T, R>): Observable<T>;
    next(value?: T): void;
    error(err: any): void;
    complete(): void;
    unsubscribe(): void;
    protected _subscribe(subscriber: Subscriber<T>): Subscription;
    asObservable(): Observable<T>;
}

我对此很新,我怀疑我的tsConfig可能有问题。这里是:

   {
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "core-js"
    ]
  }
}

有谁看到我做错了什么?我一直在寻找,但没有深刻的知识,我在黑暗中钓鱼

asp.net asp.net-mvc angular angular2-routing
1个回答
0
投票

如果从构造函数必须像的东西延伸

constructor(){
  super()
}

而且你不需要重复这些功能,只能覆盖那些具有不同实现的功能

© www.soinside.com 2019 - 2024. All rights reserved.