I am following the documentation for Aurelia Store on how to subscribe to the stream of store changes. When I import the typescript Subscription type from rxjs I get a typescript compilation error:
TS2322: Type 'import("project\node_modules\aurelia-store\node_modules\rxjs\internal\Subscription") is not assignable to type import("project\node_modules\rxjs\internal\Subscription")
Code example:
// app.ts
import { autoinject } from "aurelia-dependency-injection";
import { Store } from "aurelia-store";
import { Subscription } from 'rxjs';
import { State } from "./state";
@autoinject()
export class App {
public state: State;
private subscription: Subscription;
constructor(private store: Store<State>) {}
bind() {
this.subscription = this.store.state.subscribe(
(state) => this.state = state
);
}
unbind() {
this.subscription.unsubscribe();
}
}
I've tried doing import { Store, Subscription } from 'aurelia-store' but that doesn't work either.
EDIT:
In response to Pierre-Luc Champigny's question:
Are both your rxjs version (from Aurelia and your installed rxjs) the same?
So, aurelia-store/package.json has rxjs version "^6.2.2" and my projects package.json is "6.3.2". So, I uninstalled my rxjs version and installed the 6.2.2 version. Now typescript is giving this error message:
TS2322: Type 'import("project/node_modules/aurelia-store/node_modules/rxjs/internal/Subscription").Subscription' is not assignable to type 'import("project/node_modules/rxjs/internal/Subscription").Subscription'. Property '_parent' is protected but type 'Subscription' is not a class derived from 'Subscription'.
So, I'm not sure why this worked but I'm answering my own question just in case someone else runs into this issue.
node_modulesfoldernpm clean cache --forcenpm installThen everything started working again :)