[英]Angular/ ngrx store: argument of type 'mystate' is not assignable to parameter of type
[英]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.