I am creating event and store:
import {createEvent, createStore} from 'effector';
export default function createEventAndStore<T = {}>() {
const myEvent = createEvent<T>()
// TS2345: Argument of type '{}' is not assignable to parameter of type 'T'.
// 'T' could be instantiated with an arbitrary type which could be unrelated to '{}'.
const myStore = createStore<T>({})
myStore.on(myEvent, (_, next) => next)
}
And getting error:
TS2345: Argument of type ‘{}’ is not assignable to parameter of type ‘T’. ‘T’ could be instantiated with an arbitrary type which could be unrelated to ‘{}’.
Is it ok to cast to T: const myStore = createStore<T>({} as T)
or is there a better way to fix it?