From c608216e495476f648e83b16f4fc3feec4ac08c2 Mon Sep 17 00:00:00 2001 From: "Siddharth Gelera (reaper)" Date: Tue, 28 May 2024 09:00:51 +0530 Subject: [PATCH] fix(types): types for `fieldErrors` (#29) * chore: lint fix * fix: fieldErrors keys autocomplete * fix: a little more definitive type --- src/atomWithFormControls.ts | 4 ++-- src/atomWithValidate.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/atomWithFormControls.ts b/src/atomWithFormControls.ts index a3816b7..8547d8c 100644 --- a/src/atomWithFormControls.ts +++ b/src/atomWithFormControls.ts @@ -1,4 +1,4 @@ -import { WritableAtom, atom } from 'jotai/vanilla'; +import { atom, WritableAtom } from 'jotai/vanilla'; import type { ExtractTypeOfValidatorValue, Validator, @@ -19,7 +19,7 @@ export type ActionableNext = { export type FormControls = { isValid: boolean; fieldErrors: { - [k: string]: any; + [k in Keys]: string | Error | any; }; touched: Record; focused: Record; diff --git a/src/atomWithValidate.ts b/src/atomWithValidate.ts index de9fc74..0e18930 100644 --- a/src/atomWithValidate.ts +++ b/src/atomWithValidate.ts @@ -1,5 +1,5 @@ import { atom } from 'jotai/vanilla'; -import type { WritableAtom, SetStateAction } from 'jotai/vanilla'; +import type { SetStateAction, WritableAtom } from 'jotai/vanilla'; export type CommonState = { value: Value;