Skip to content

Commit

Permalink
fix: ts error TS2742
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 30, 2024
1 parent 643de2a commit e39bfb1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@
"pnpm": {
"patchedDependencies": {
"sonner@1.5.0": "patches/sonner@1.5.0.patch",
"hono@4.4.7": "patches/hono@4.4.7.patch"
"hono@4.4.7": "patches/hono@4.4.7.patch",
"immer@10.1.1": "patches/immer@10.1.1.patch"
}
},
"simple-git-hooks": {
Expand Down
13 changes: 13 additions & 0 deletions patches/immer@10.1.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/dist/immer.d.ts b/dist/immer.d.ts
index 2cb6cddda28d1fb226fc9dc5fc4b64ec7fc55a9c..161cf402a794712dc700c6b63c138622b0a3dc4c 100644
--- a/dist/immer.d.ts
+++ b/dist/immer.d.ts
@@ -48,7 +48,7 @@ type PatchListener = (patches: Patch[], inversePatches: Patch[]) => void;
* Utility types
*/
type PatchesTuple<T> = readonly [T, Patch[], Patch[]];
-type ValidRecipeReturnType<State> = State | void | undefined | (State extends undefined ? typeof NOTHING : never);
+export type ValidRecipeReturnType<State> = State | void | undefined | (State extends undefined ? typeof NOTHING : never);
type ReturnTypeWithPatchesIfNeeded<State, UsePatches extends boolean> = UsePatches extends true ? PatchesTuple<State> : State;
/**
* Core Producer inference
13 changes: 8 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions src/renderer/src/lib/defineQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ import type {
QueryFunction,
QueryKey,
} from "@tanstack/react-query"
import type { Draft, nothing } from "immer"
import type { Draft, ValidRecipeReturnType } from "immer"
import { produce } from "immer"

import { queryClient } from "./query-client"

// From immer, but immer not export this type
type ValidRecipeReturnType<State> =
| State
| void
| undefined
| (State extends undefined ? typeof nothing : never)

export type DefinedQuery<TQueryKey extends QueryKey, TData> = Readonly<{
key: TQueryKey
fn: QueryFunction<TData>
Expand Down

0 comments on commit e39bfb1

Please sign in to comment.