✅ TL;DR - zustand 4.4.5 버전에 문제가 있었다. 4.4.6 이상 버전으로 업데이트하면 된다

 

src/stores/user.ts:30:3 - error TS2345: Argument of type 'StateCreator<UserStore, [], [["zustand/devtools", never], ["zustand/persist", unknown]]>' is not assignable to parameter of type 'StateCreator<UserStore, [], [never, unknown][]>'.
  Type 'StateCreator<UserStore, [], [["zustand/devtools", never], ["zustand/persist", unknown]]>' is not assignable to type '{ $$storeMutators?: [never, unknown][] | undefined; }'.
    Types of property '$$storeMutators' are incompatible.
      Type '[["zustand/devtools", never], ["zustand/persist", unknown]] | undefined' is not assignable to type '[never, unknown][] | undefined'.
        Type '[["zustand/devtools", never], ["zustand/persist", unknown]]' is not assignable to type '[never, unknown][]'.
          Type '["zustand/devtools", never] | ["zustand/persist", unknown]' is not assignable to type '[never, unknown]'.
            Type '["zustand/devtools", never]' is not assignable to type '[never, unknown]'.
              Type at position 0 in source is not compatible with type at position 0 in target.
                Type 'string' is not assignable to type 'never'.

ts 트랜스파일이 안된다

 

에디터에서는 이런식으로 나온다. persist 미들웨어가 문제다

 

 

Persist Partialize not working with TypeScript · Issue #1053 · pmndrs/zustand

I've been having trouble getting Zustand's persist partialize middleware, to work with TypeScript. I'm not sure what type to provide and where. Thanks in advance! Here is the TS error I am currentl...

github.com

 

 

Type breaks for curried create when using persist middleware since 4.4.5 · pmndrs/zustand · Discussion #2163

Noticed upgrading to 4.4.5 breaks our zustand context with type errors when using persist middleware. TimeLine is our state in this case: Argument of type 'StateCreator<TimeLine, [], [["zustand/per...

github.com

 

Release v4.4.6 · pmndrs/zustand

v4.4.5 has an issue with some TypeScript configs about module resolution. It should be fixed now. Thanks for the patience. What's Changed Update export types by @dbritto-dev in #2170 New Contribu...

github.com

관련 이슈 및 릴리즈 노트

아무튼 zustand 4.4.6 이상 버전으로 업그레이드 하면 해결된다고 한다

 

$ pnpm update zustand
Packages: +1 -1
+-
Progress: resolved 342, reused 311, downloaded 1, added 1, done

dependencies:
- zustand 4.4.5
+ zustand 4.4.7

Done in 1.5s

pnpm은 위처럼 업데이트 할 수 있다.

업데이트 뒤에 vscode를 껐다 켜야 에러가 사라진다

 

반응형