34 Commits

Author SHA1 Message Date
Andy Zhou
af7ff21190
fix(middleware): devtools type error #2700 (#2875)
* fix: add an inferred generic U to CreateStoreImpl

* fix: add inferred generic U variables to both Devtools and DevtoolsImpl

* test: add tests for issue #2700

* revert impl types

* code styling

---------

Co-authored-by: daishi <daishi@axlight.com>
2024-12-04 22:00:01 +09:00
Christian van der Loo
d7345da7cf
Fix Immer type inference for setState (#2696)
* fix(immer): tweak type inference to base `setState` type off of store `setState` instead of `getState`

* fix(immer): instead, infer type directly from StoreApi<T>["setState"]

* fix(immer): instead of using `StoreApi`, extract from A2 the non-functional component of state

* docs: add comment describing why it is not derived from `A1`

* test: add example middleware that modifies getState w/o setState

* fix: add assertion for inner `set` and `get` types

---------

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2024-08-27 10:10:47 +09:00
Daishi Kato
a00f3fa1ff
chore(deps): update dependencies (#2680) 2024-08-15 11:13:14 +09:00
Daishi Kato
9857a676a9
refactor: revisit prettier config to be minimal (#2193) 2023-11-14 12:19:51 +09:00
Daishi Kato
5777a65cf5
chore(deps): update dev dependencies (#1965) 2023-08-01 10:42:18 +09:00
Arjun Vegda
496a466c2c
chore(tests): migrate to vitest (#1753)
* test: migrate to vitest

* test: try #1 remove CI-MATRIX tags

* test: try 2 remove import/require replace

* chore: remove unused scripts/assignments

* chore(test-multiple-builds.yml): remove import/require replace script

* fix merging main

---------

Co-authored-by: daishi <daishi@axlight.com>
2023-05-04 13:25:24 +09:00
Daishi Kato
9062ca634f
chore: remove __DEV__ with ts-jest (#1598)
* wip: use ts-jest instead of swc/jest

* use esm in jest

* remove types/jest

* remove __DEV__

* fix rollup config

* fix github workflow

* hack jest.Mock

* wip: ts

* skipLibCheck for older ts 2

* wip: ts

* wip: workflow...

* wip: workflow...

* wip: workflow...

* experiment...

* experiment...2

* experiment...3

* experiment...4

* jest preset
2023-02-10 19:05:12 +09:00
Daishi Kato
0b55a3d74b
feat: deprecate default export (#1514) 2023-01-10 18:13:25 +09:00
Daishi Kato
1e986ec97f
feat(middleware/persist): new storage option (#1463)
* feat(middleware/persist): new storage option

* fix typo
2023-01-01 09:57:19 +09:00
Łukasz Rabiec
ed12c7edab
fix(types)(middleware/devtools): fix action type in devtools's setState (#1183)
* added payload to setState() in devtools middleware

* adjusted tests

* changed payload to any property name

* adjusted docs

* prettier readme.md

* adjusted for extends

* adjusted immer's setState

* Revert "adjusted immer's setState"

This reverts commit 50ce327bf0031a0ec61177b47733f397de036758.

* changed order of immer and devtools in tests

* added test for action with payload type in immer/devtools

* removed unnecessary test

* Update tests/middlewareTypes.test.tsx

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2022-08-19 07:10:50 +09:00
Daishi Kato
fa581ddd9b
fix(docs): useBoundStore instead of useStore (#1125)
* fix(docs): useBoundStore instead of useStore

* run prettier
2022-07-26 08:58:43 +09:00
Daishi Kato
a4b08a10f3
refactor(types): avoid using deprecated types in tests (#1126) 2022-07-25 18:54:32 +09:00
Daishi Kato
060c092694
fix(types): use TS interfaces only for public api (#1106) 2022-07-20 08:48:43 +09:00
Daishi Kato
3d764b0a4a
refactor: prefer interfaces (#1012) 2022-06-18 22:43:25 +09:00
Daishi Kato
2a2c180c73
fix(middleware): separate immer middleware (#915) 2022-04-18 10:06:17 +09:00
Devansh Jethmalani
99cddcf76f
breaking(types): Add higher kinded mutator types (#725)
* imaginary code that uses uSES

* revert backward compatibility code as this is not going to be v4

* use use-sync-external-store

* revert to react 17

* handle error by our own

* v4.0.0-alpha.2

* fix&refactor a bit

* update uSES experimental package

* remove error propagation hack

* update size snapshot

* update uSES and add dts

* split react.ts and no export wild

* split useStore impl

* context to follow the new api, export wild again

* v4.0.0-alpha.3

* add missing await

* update uSES

* update uSES

* uses uSES extra!

* v4.0.0-alpha.3

* fix(types): Rename from UseStore to UseBoundStore

* breaking(types): drop deprecated UseStore type

* breaking(core): drop v2 hook compatibility

* breaking(middleware): drop deprecated persist options

* breaking(core): drop deprecated store.subscribe with selector

* update uSES

* fix update uSES

* v4.0.0-alpha.5

* combine subscribe type

* intentional undefined type

* add useDebugValue

* update uSES

* update uSES types

* breaking(middleware): make persist options.removeItem required

* update uSES

* v4.0.0-alpha.6

* fix(readme): remove memoization section which is no longer valid with uSES

* feat(readme): add new createStore/useStore usage

* update useSES

* update uSES and deps

* v4.0.0-alpha.7

* update uSES

* update uSES

* shave bytes

* vanilla: add higher kinded mutator types

* persist: add higher kinded mutator types

* persist: try to minimize diff

* use `PopArgument` in vanilla too

* update uSES

* use overloads instead of `createWithState`

* avoid symbols

* add new types to middlewares

* add new types react

* add new types to context

* fix persist types

* add immer

* migrate middleware type tests

* fix react type, export `UseBoundStore`

* migrate vanilla type tests

* rename `_createStore` to `createStoreImpl`

* Default to no mutations in `StateCreator`

* migrate context.test.tsx

* fix devtools.test.tsx type erros

* context: remove callsignature in useStoreApi

* context: remove `UseContextStore` type

* context: fix useBoundStore type

* context: keep `UseContextStore` for tooltip just don't export it

* react: remove duplicate overload in create

* export `WithPersist`

* devtools: preserve try/catch

* devtools: preserve window check

* add a test case for v3 style create

* devtools: preverse test fix from base branch

* remove StoreApiWithFoo types, don't export WithFoo types

* style

* devtools: preverse `originalIsRecording` change

* fix bug in devtools

* empty commit

* 4.0.0-beta.1

* fix lint

* style

* export immer fix tests

* style, minor fixes

* devtools: fix test

* Update tests/devtools.test.tsx

* breaking(middleware/devtools): use official devtools extension types

* type object.create

* avoid emitting @redux-devtools/extension

* fix type with any

* refactor

* fix yarn lock

* temporary fix #829

* v4.0.0-beta.2

* fix lint

* lock date-fns version

* test middleware subtyping

* fix errors in conflict resolution

* lock testing-library/react alpha version

* more correct (and strict) persist types

* migrate tests

* wip release notes

* fix devtools merge with base

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* add a test case for persist with partialize option

* update readme

* fix lint

* immer: mutate `store.setState`

* fix devtools merge with base

* immer: fix mutations order

* changes in readme

* move and rename v4 migration md

* add `combine` usage in readme

* typos

* create separate md for typescript, add common recipes

* minor fixes

* devtools: minor type fix
(probably I copy pasted from persist and forgot to remove `U`)

* add more migrations

* context: fix import

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* devtools: minor refactor
rearrange code for better diff

* fix lint: run prettier

* wip

* uSES rc.1

* getServerState for #886, no types yet

* uSES v1

* devtools: remove deprecations and warnings

* fix tests

* v4.0.0-beta.2

* wip

* migrate tests

* persist: keep diff minimal

* fix merge in package.json and yarn.lock

* fix merge for persist

* don't use `import type`

* docs(typescript): add slices pattern

* fix selector & equals types
for inference with useCallback, see issue #812

* add test for setState with replace

* remove undefined selector overload

* make immer more generic

* make devtools replace-friendly and more correctly typed

* migrate tests

* make setState bivariant to make the state covariant

* devtools: return the result of `setState`

* devtools: make the fallback branch in `StoreSetStateWithAction` bivariant too
(I forgot to make this bivaraint)

* remove strict replace

* fix lint

Co-authored-by: daishi <daishi@axlight.com>
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2022-04-18 09:14:00 +09:00
Devansh Jethmalani
a418fd7480
Migrations regarding higher kinded mutators for v4 (#772)
* add `Mutate` for migration path

* deprecate `PartialState`

* deprecate `StateSliceListener`

* add v4 version of `UseContextStore` for migration

* revert and deprecate `UseContextStore`

* subscribeWithSelector: fix deprecation message, add a test case

* subscribeWithSelector: fix overloads

* persist: deprecate `StoreApiWithPersist`

* subscribeWithSelector: update deprecation message

* redux: deprecate `StoreApiWithRedux`

* devtools: deprecate `StoreApiWithDevtools`

* migrate middleware tests

* update deprecation message to mention test file

* style

* don't export `WithPersist`
2022-02-11 08:23:24 +09:00
Daishi Kato
5b938fbbff
feat(build): use __DEV__ to control development mode (#789)
* feat(build): use __DEV__ to control development mode

* fix workflow

* missing env in systemjs build
2022-02-10 08:45:43 +09:00
Daishi Kato
e3566f9b54
chore(tests): for issue 650 (#651)
* chore(tests): for issue 650

* use another workaround
2021-11-15 20:12:16 +09:00
Daishi Kato
62238d4920
fix(types): fix core types to better handle middleware types (#641)
* fix(types): fix core types to better handle middleware types

* fix eslint
2021-11-09 22:47:03 +09:00
Daishi Kato
2bc4de3c60
feat(middleware): devtools to patch api.setState with namedSet and fix middleware types (#634)
* wip: patch api.setState with devtools middleware

* wip: middleware type tests

* fix middleware types

* oh, that was it!

* fix a test, add comments
2021-11-04 07:30:38 +09:00
Daishi Kato
6f95f128bf
fix(tests): add #632 example and improve middleware types tests (#633)
* fix(tests): add #632 example

* update #632 example in test

* update #632 example in test again

* add #631 example in test

* add a link to middleware type test in readme

* change/simplify middleware type test

* comment on same line

* fix: middleware test for single subscribeWithSelector

* empty commit

* link to immer reference implementation in readme

* update readme
2021-11-03 18:02:44 +09:00
Anatole Lucet
8665dd6cfe
feat(middleware): add persist api (#624)
* feat(persist middleware): add api

* workaround types

* add comment

Co-authored-by: daishi <daishi@axlight.com>
2021-11-02 20:46:55 +09:00
Daishi Kato
3889419fb5
chore(tests): more typing example with subscribeWithSelector (#621) 2021-11-02 20:45:55 +09:00
Daishi Kato
7e94455d27
fix(middleware): simplify middleware types and allow explicit typing (#617)
* chore(tests): add a use case combining many middleware

* simplify middleware types and allow explicit typing reverting some of #601

* fix context tests

* prettier

* refine middleware type test for more coverage and readability
2021-10-30 09:23:25 +09:00
Daishi Kato
ad318f3ebd
fix(middleware): types and devtools (#613)
* fix(middleware): types and devtools

* a fix

* make combine clean and always accept 3rd name arg

* revert fn name
2021-10-27 00:18:58 +09:00
Daishi Kato
ae888bdb05
fix(tests): immer middleware type test (#610)
* fix(tests): immer middleware type test

* empty commit

* sync with #613
2021-10-27 00:04:41 +09:00
Daishi Kato
37ff965563
feat(middleware): subscribeWithSelector middleware (#603)
* feat(middleware): subscribeWithSelector middleware, deprecating the core feature

* update readme

* update readme
2021-10-21 22:51:10 +09:00
Daishi Kato
5f5527d590
fix(types): Rename from UseStore to UseBoundStore (#595) 2021-10-21 18:02:50 +09:00
Daishi Kato
10cb45c201
feat(types): better middleware support (#601)
* feat(types): better middleware support

* some more trial

* some more trial

* Revert "some more trial"

This reverts commit c54bf7cb75faa58e6df4325679ea5f815b594d01.

* some more trial

* some more trial

* some more trial

* some more trial

* Revert "some more trial"

This reverts commit 3aef9e229a54f18a901a1aea557cb05b46e8f2ab.

* some more trial

* Revert "some more trial"

This reverts commit fce0cb4c3e012adb35e5240e64d31cde3f7790f8.

* some more trial

* some more trial

* some more trial

* some more trial

* add redux middleware type test

* fix with type alias

* add devtools and redux combination test

* combine to support named set

* remove duplicated types
2021-10-21 17:51:24 +09:00
Daishi Kato
ae86695c44
refactor(test): use aliases (#571) 2021-09-29 00:55:12 +09:00
marcoSven
bbd3793328
Allow optional REDUX DEVTOOLS "options" object (#540)
* Allow optional REDUX DEVTOOLS "options" object

## Why is this change needed?
Unable to display Maps/Sets

## How does it address the issue?
optional serialize date, regex, undefined, nan, infinity,
error, symbol, map & set

## breaking change prev "prefix" option
prefix?: string -> options?: { name?: string }

https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize

https://github.com/pmndrs/zustand/issues/249

* backward compatible with "prefix" store name option

* Update readme.md
2021-08-26 22:53:40 +09:00
Daishi Kato
e47ea038fd
chore: update eslintrc and use react-jsx (#531) 2021-08-15 19:44:06 +09:00
Dương Tấn Huỳnh Phong
836aeaeccd
make type NamedSet compatible with type SetState (#441) 2021-06-20 22:33:29 +09:00