oslabs-beta / Zusty

Zustand Dev Tools
102 stars 2 forks source link

No TS support? #45

Closed decipher-cs closed 8 months ago

decipher-cs commented 9 months ago

import zustymiddleware from 'zustymiddleware' throws the following error:

Could not find a declaration file for module 'zustymiddleware'. 'node_modules/.pnpm/zustymiddleware@1.2.0/node_modules/zustymiddleware/index.js' implicitly has an 'any' type. Try `npm i --save-dev @types/zustymiddleware` if it exists or add a new declaration (.d.ts) file containing `declare module 'zustymiddleware';` [7016]

Is there going to be support for it in the future?

React: v18.2
Zustand: v4.5
Typescript: v5.2
zustymiddleware: v1.2.0
JaeBrian commented 9 months ago

Hey deciper-cs, we just implemented Zusty for TypeScript, if you follow the README, you will find our new npm module for Typescript and how to implement it for Typescript. Let us know if you have any other issues, thank you!

@decipher-cs

decipher-cs commented 9 months ago

Hate to be the bearer of bad news but it doesn't work. Here's the error I got after copying the example from your npm's readme verbatim.

Argument of type 'Middleware' is not assignable to parameter of type 'StateCreator<BearState, [], [], BearState>'.
  Type 'Middleware' is not assignable to type '(setState: (partial: BearState | Partial<BearState> | ((state: BearState) => BearState | Partial<BearState>), replace?: boolean | undefined) => void, getState: () => BearState, store: StoreApi<...>) => BearState'.
    Type 'Store' is missing the following properties from type 'BearState': bears, increase, removeAllBearstypescript(2345)

Here's a sandbox. codesandbox

DanaKaplan944 commented 8 months ago

Hi @decipher-cs thanks for the sandbox and letting us know. The TS middleware has now been fixed. Let us know if you have any further issues.