Repository: effector/effector (ts)

Issue:
`useUnit` object form adds `(payload: void) => void` for `Event<void>` instead of `() => void`
**What is the current behavior:**

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYygUwIYzQUQG5oB28AvnAGZQQhwDka55ayM0tA3AFCiSyJwBXAM5oAqoWCkKVGvUbNWUALToMLDp07IIhIfDQFiAQTgBeFKuz4iMADx4IwACYA+ABQBKTdt3wkhCBgAeQBrODJzYTEJGDd-QNCALjgDGxMSDy4fPTgIMMiRcUk3VOMvTgBhakhCGziUDAAbRoAjNRDkgOCwjMrqnTqkZCbW9uS88PLyAUIWYB04KvAB4nrh5rbkHuShkc2OuBLDGGSZkICAd0IPMxc4B2dJxE44V7gAene4MAwhIU4SJogA

```ts
import { createEvent } from 'effector';
import { useUnit } from 'effector-react';

const eventA = createEvent<void>()

const { notOk } = useUnit({ notOk: eventA });
const ok = useUnit(eventA)

Component({ callback: notOk })
Component({ callback: ok })

function Component({ callback }: { callback: (event: unknown) => void }) {
    // ...
}
```

**What is the expected behavior:**

Same behaviour in object form and in simple form, no error. It is current behaviour of `useEvent`

**Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:**

`effector-react` with `useUnit`

Pull request description:
Fix useUnit typings
### Conventions
- [x] Please check your messages [against the guidelines](https://cbea.ms/git-commit/) if not, perform [interactive rebase](https://thoughtbot.com/blog/git-interactive-rebase-squash-amend-rewriting-history)
- [x] [Link an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) your pull request closes or relates

Resolves #740 

Patch:
diff --git a/packages/effector-react/index.d.ts b/packages/effector-react/index.d.ts
index d82ba60f..cd91c33b 100644
--- a/packages/effector-react/index.d.ts
+++ b/packages/effector-react/index.d.ts
@@ -159,9 +159,13 @@ export function useUnit<
   list: [...List],
 ): {
   [Key in keyof List]: List[Key] extends Event<infer T>
-    ? (payload: T) => T
+    ? T extends void
+      ? () => void
+      : (payload: T) => T
     : List[Key] extends Effect<infer P, infer D, any>
-    ? (payload: P) => Promise<D>
+    ? P extends void
+      ? () => Promise<D>
+      : (payload: P) => Promise<D>
     : List[Key] extends Store<infer V>
     ? V
     : never
@@ -172,9 +176,13 @@ export function useUnit<
   shape: Shape,
 ): {
   [Key in keyof Shape]: Shape[Key] extends Event<infer T>
-    ? (payload: T) => T
+    ? T extends void
+      ? () => void
+      : (payload: T) => T
     : Shape[Key] extends Effect<infer P, infer D, any>
-    ? (payload: P) => Promise<D>
+    ? P extends void
+      ? () => Promise<D>
+      : (payload: P) => Promise<D>
     : Shape[Key] extends Store<infer V>
     ? V
     : never
diff --git a/packages/effector-solid/index.d.ts b/packages/effector-solid/index.d.ts
index f09468da..2d4d6fb6 100644
--- a/packages/effector-solid/index.d.ts
+++ b/packages/effector-solid/index.d.ts
@@ -41,28 +41,38 @@ export function useUnit<State>(store: Store<State>): Accessor<State>
 export function useUnit(event: Event<void>): () => void
 export function useUnit<T>(event: Event<T>): (payload: T) => T
 export function useUnit<R>(fx: Effect<void, R, any>): () => Promise<R>
-export function useUnit<T, R>(
-  fx: Effect<T, R, any>,
-): (payload: T) => Promise<R>
-export function useUnit<List extends (Event<any> | Effect<any, any> | Store<any>)[]>(
-  list: [...List]
+export function useUnit<T, R>(fx: Effect<T, R, any>): (payload: T) => Promise<R>
+export function useUnit<
+  List extends (Event<any> | Effect<any, any> | Store<any>)[],
+>(
+  list: [...List],
 ): {
   [Key in keyof List]: List[Key] extends Event<infer T>
-    ? (payload: T) => T
+    ? T extends void
+      ? () => void
+      : (payload: T) => T
     : List[Key] extends Effect<infer P, infer D, any>
-      ? (payload: P) => Promise<D>
-      : List[Key] extends Store<infer V>
-        ? Accessor<V>
-        : never
+    ? P extends void
+      ? () => Promise<D>
+      : (payload: P) => Promise<D>
+    : List[Key] extends Store<infer V>
+    ? Accessor<V>
+    : never
 }
-export function useUnit<Shape extends Record<string, Event<any> | Effect<any, any, any> | Store<any>>>(
-  shape: Shape
+export function useUnit<
+  Shape extends Record<string, Event<any> | Effect<any, any, any> | Store<any>>,
+>(
+  shape: Shape,
 ): {
   [Key in keyof Shape]: Shape[Key] extends Event<infer T>
-    ? (payload: T) => T
+    ? T extends void
+      ? () => void
+      : (payload: T) => T
     : Shape[Key] extends Effect<infer P, infer D, any>
-      ? (payload: P) => Promise<D>
-      : Shape[Key] extends Store<infer V>
-        ? Accessor<V>
-        : never
+    ? P extends void
+      ? () => Promise<D>
+      : (payload: P) => Promise<D>
+    : Shape[Key] extends Store<infer V>
+    ? Accessor<V>
+    : never
 }


Test patch:
diff --git a/src/types/__tests__/effector-react/effectorReact.test.tsx b/src/types/__tests__/effector-react/effectorReact.test.tsx
index b41c4c04..956356b3 100644
--- a/src/types/__tests__/effector-react/effectorReact.test.tsx
+++ b/src/types/__tests__/effector-react/effectorReact.test.tsx
@@ -204,3 +204,30 @@ test('useUnit should not allow non-unit values', () => {
     "
   `)
 })
+
+test('useUnit should correctly resolve void events and effects in shape mode', () => {
+  const event = createEvent<void>()
+  const effect = createEffect(() => {})
+
+  function x(callback: (e: unknown) => void | Promise<void>) {
+
+  }
+
+  const Comp = () => {
+    const {runEvent} = useUnit({runEvent: event})
+    const {runEffect} = useUnit({runEffect: effect})
+    const [runEvent1] = useUnit([event])
+    const [runEffect1] = useUnit([effect])
+
+    x(runEvent)
+    x(runEffect)
+    x(runEvent1)
+    x(runEffect1)
+  }
+
+  expect(typecheck).toMatchInlineSnapshot(`
+    "
+    no errors
+    "
+  `)
+})