You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I have issues with Bunshi lib when I try to bump Typescript from 4.9.5 to 5.0.4 (and every next version behaves the same).
It looks like MoleculeOrInterface<T> fails to resolve the type T for MoleculeGetter and react hooks like useMolecule etc.
type T is resolved to unknown: Argument of type Atom<string> is not assignable to parameter of type Atom<unknown> (in case of Jotai atoms). In Typescript 4.9.5 and previous it worked just fine.
Reproduction
I have modified old-typescript example for typescript 5 with following react-import-test.ts:
import { molecule, Molecule, useMolecule } from "bunshi/react";
import { atom } from "jotai/vanilla/atom";
type Atom<T> = {a: T};
const useAtom =<T>(a: Atom<T>): T => a['a'];
export const ExampleMolecule = molecule<Atom<string>>(() => {
return {a: "I am a type test"};
});
export const DerivedMolecule = molecule((mol) => {
const anAtom = mol(ExampleMolecule);
return atom((get) => {
return get(anAtom) + " and I can be derived"; // fails here: Argument of type Atom<string> is not assignable to parameter of type Atom<unknown>
});
});
export const useMoleculeAtom = <T>(
molecule: Molecule<T>
) => {
return useAtom(useMolecule(molecule)); // fails here: Argument of type unknown is not assignable to parameter of type Atom<unknown>
};
export const useExample = useMoleculeAtom(DerivedMolecule);
It occurs when molecule has some generic type as type. It works for non-generics and plain data types.
But since I use Bunshi together with Jotai - it's a blocker for me :/
I couldn't find anything helpful in Typescript changelog.
The text was updated successfully, but these errors were encountered:
Hello!
I have issues with Bunshi lib when I try to bump Typescript from 4.9.5 to 5.0.4 (and every next version behaves the same).
It looks like
MoleculeOrInterface<T>
fails to resolve the typeT
forMoleculeGetter
and react hooks likeuseMolecule
etc.type
T
is resolved tounknown
:Argument of type Atom<string> is not assignable to parameter of type Atom<unknown>
(in case of Jotai atoms). In Typescript 4.9.5 and previous it worked just fine.Reproduction
I have modified
old-typescript
example for typescript 5 with followingreact-import-test.ts
:It occurs when molecule has some generic type as type. It works for non-generics and plain data types.
But since I use Bunshi together with Jotai - it's a blocker for me :/
I couldn't find anything helpful in Typescript changelog.
The text was updated successfully, but these errors were encountered: