簡體   English   中英

“typeof Store”類型的參數不可分配給“Store”類型的參數<appstate> '</appstate>

[英]Argument of type 'typeof Store' is not assignable to parameter of type 'Store<AppState>'

我正在嘗試擴展使用ngrx的 angular 服務,但出現此類型錯誤

Argument of type 'typeof Store' is not assignable to parameter of type 'Store<AppState>'

這是我的父母 class:

import { Store } from '@ngrx/store';
import { AppState } from '../store/file-uploader.state';
import { AbstractStorage } from '@storage';

export class FileUploaderService {
    constructor(
        private store: Store<AppState>,
        private storage: AbstractStorage,
    ) { }
}

還有我的孩子 class:

import { Store } from '@ngrx/store';
import { AppState } from '../store/file-uploader.state';
import { AbstractStorage } from '@storage';

export class DataSourceService extends FileUploaderService implements AbstractFileUploader  {
    constructor() {
        super(Store, AbstractStorage)
    }
}

我必須將這 2 個 arguments 傳遞給 super。 我試過傳遞Store<AppState> ,但它說它使用Appstate作為值,而不是類型。 所以我不知道如何輸入這個參數。 有誰知道如何正確聲明這個超級?

您應該將實例傳遞給super而不是類型。 您可以嘗試以下代碼,看看是否有幫助:

    export class DataSourceService extends FileUploaderService implements AbstractFileUploader  {
      constructor(private store: Store<AppState>, private storage: AbstractStorage) {
          super(store, storage);
      }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM