Reputation: 63
I'm trying to extend an angular service that uses ngrx
and I'm getting this type error
Argument of type 'typeof Store' is not assignable to parameter of type 'Store<AppState>'
Here is my parent 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,
) { }
}
And my child 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)
}
}
I have to pass these 2 arguments to super. I've tried passing Store<AppState>
, but it says it's using Appstate
as a value, not a type. So I don't know how to type this arg. Does anyone know how to declare this super correctly?
Upvotes: 2
Views: 3772
Reputation: 3171
You should be passing the instances to super
and not type. You can try below code and see if it helps:
export class DataSourceService extends FileUploaderService implements AbstractFileUploader {
constructor(private store: Store<AppState>, private storage: AbstractStorage) {
super(store, storage);
}
}
Upvotes: 1