Skip to content

Commit

Permalink
fix typing of useControls
Browse files Browse the repository at this point in the history
  • Loading branch information
konodyuk committed Dec 1, 2023
1 parent abd32d9 commit 6072972
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ui/hooks/controls.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useCallback, useContext, useEffect, useState } from "react";
import { Contexts } from "..";

export interface ControlSpec {
value: string;
setValue: (value: string) => Promise<string>;
submitValue: (value: string) => Promise<string>;
export interface ControlSpec<T extends string | number | boolean> {
value: T;
setValue: (value: T) => Promise<T>;
submitValue: (value: T) => Promise<T>;
}

export type ControlsResult<T> = {
[K in keyof T]: ControlSpec;
export type ControlsResult<T extends Record<string | number, string | number | boolean>> = {
[K in keyof T]: ControlSpec<T[K]>;
} & { value: string; submitCurrentValue: () => void };

export function useControls<T extends Record<string | number, any>>({
export function useControls<T extends Record<string | number, string | number | boolean>>({
parse,
compose,
}: {
Expand Down

0 comments on commit 6072972

Please sign in to comment.