Skip to content

Commit

Permalink
chore: add typecheck and fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeiscontent committed May 8, 2024
1 parent 4aab4cb commit c841225
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/conform-dom/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ function shouldNotify<Schema>(
return false;
}

export function createFormContext<
export function unstable_createFormContext<
Schema extends Record<string, any>,
FormError = string[],
FormValue = Schema,
Expand Down
2 changes: 1 addition & 1 deletion packages/conform-dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export {
type FormContext,
type SubscriptionSubject,
type SubscriptionScope,
createFormContext as unstable_createFormContext,
unstable_createFormContext,
} from './form';
export { type FieldElement, isFieldElement } from './dom';
export {
Expand Down
5 changes: 3 additions & 2 deletions packages/conform-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
},
"scripts": {
"build:js": "rollup -c",
"build:ts": "tsc",
"build:ts": "tsc --emitDeclarationOnly",
"build": "pnpm run \"/^build:.*/\"",
"dev:js": "pnpm run build:js --watch",
"dev:ts": "pnpm run build:ts --watch",
"dev": "pnpm run \"/^dev:.*/\"",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"typecheck": "tsc --noEmit"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/conform-dom/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type SubmissionState = {
validated: Record<string, boolean>;
};

export type SubmissionContext<Value = null, FormError = string[]> = {
export type SubmissionContext<Value = unknown, FormError = string[]> = {
intent: Intent | null;
payload: Record<string, unknown>;
fields: Set<string>;
Expand Down
1 change: 0 additions & 1 deletion packages/conform-dom/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"noUncheckedIndexedAccess": true,
"strict": true,
"declaration": true,
"emitDeclarationOnly": true,
"composite": true,
"skipLibCheck": true
}
Expand Down
4 changes: 2 additions & 2 deletions packages/conform-react/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
type SubscriptionScope,
type SubscriptionSubject,
type FormOptions as BaseFormOptions,
unstable_createFormContext as createBaseFormContext,
unstable_createFormContext,
formatPaths,
getPaths,
isPrefix,
Expand Down Expand Up @@ -479,7 +479,7 @@ export function createFormContext<
options: FormOptions<Schema, FormError, FormValue>,
): FormContext<Schema, FormError, FormValue> {
let { onSubmit, ...rest } = options;
const context = createBaseFormContext(rest);
const context = unstable_createFormContext(rest);

return {
...context,
Expand Down
4 changes: 2 additions & 2 deletions packages/conform-react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export {
} from './context';
export { useForm, useFormMetadata, useField } from './hooks';
export {
Control as unstable_Control,
useControl as unstable_useControl,
unstable_Control,
unstable_useControl,
useInputControl,
} from './integrations';
export {
Expand Down
12 changes: 8 additions & 4 deletions packages/conform-react/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ export function useInputValue<
return [value, setValue] as const;
}

export function useControl<
export function unstable_useControl<
Value extends string | string[] | Array<string | undefined>,
>(meta: { key?: Key | null | undefined; initialValue?: Value | undefined }) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [value, setValue] = useInputValue(meta);
// eslint-disable-next-line react-hooks/rules-of-hooks
const { register, change, focus, blur } = useInputEvent();
const handleChange = (
value: Value extends string ? Value : string | string[],
Expand Down Expand Up @@ -377,13 +379,15 @@ export function useInputControl<
};
}

export function Control<
export function unstable_Control<
Value extends string | string[] | Array<string | undefined>,
>(props: {
meta: { key?: Key | null | undefined; initialValue?: Value | undefined };
render: (control: ReturnType<typeof useControl<Value>>) => React.ReactNode;
render: (
control: ReturnType<typeof unstable_useControl<Value>>,
) => React.ReactNode;
}) {
const control = useControl(props.meta);
const control = unstable_useControl(props.meta);

return props.render(control);
}
5 changes: 3 additions & 2 deletions packages/conform-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
},
"scripts": {
"build:js": "rollup -c",
"build:ts": "tsc",
"build:ts": "tsc --emitDeclarationOnly",
"build": "pnpm run \"/^build:.*/\"",
"dev:js": "pnpm run build:js --watch",
"dev:ts": "pnpm run build:ts --watch",
"dev": "pnpm run \"/^dev:.*/\"",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"typecheck": "tsc --noEmit"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/conform-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"noUncheckedIndexedAccess": true,
"strict": true,
"declaration": true,
"emitDeclarationOnly": true,
"composite": true,
"skipLibCheck": true
}
Expand Down
5 changes: 3 additions & 2 deletions packages/conform-validitystate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
},
"scripts": {
"build:js": "rollup -c",
"build:ts": "tsc",
"build:ts": "tsc --emitDeclarationOnly",
"build": "pnpm run \"/^build:.*/\"",
"dev:js": "pnpm run build:js --watch",
"dev:ts": "pnpm run build:ts --watch",
"dev": "pnpm run \"/^dev:.*/\"",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"typecheck": "tsc --noEmit"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/conform-validitystate/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"declaration": true,
"emitDeclarationOnly": true,
"composite": true,
"skipLibCheck": true
}
Expand Down
5 changes: 3 additions & 2 deletions packages/conform-yup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
},
"scripts": {
"build:js": "rollup -c",
"build:ts": "tsc",
"build:ts": "tsc --emitDeclarationOnly",
"build": "pnpm run \"/^build:.*/\"",
"dev:js": "pnpm run build:js --watch",
"dev:ts": "pnpm run build:ts --watch",
"dev": "pnpm run \"/^dev:.*/\"",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"typecheck": "tsc --noEmit"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/conform-yup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"noUncheckedIndexedAccess": true,
"strict": true,
"declaration": true,
"emitDeclarationOnly": true,
"composite": true,
"skipLibCheck": true
}
Expand Down
5 changes: 3 additions & 2 deletions packages/conform-zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
},
"scripts": {
"build:js": "rollup -c",
"build:ts": "tsc",
"build:ts": "tsc --emitDeclarationOnly",
"build": "pnpm run \"/^build:.*/\"",
"dev:js": "pnpm run build:js --watch",
"dev:ts": "pnpm run build:ts --watch",
"dev": "pnpm run \"/^dev:.*/\"",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"typecheck": "tsc --noEmit"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/conform-zod/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"noUncheckedIndexedAccess": true,
"strict": true,
"declaration": true,
"emitDeclarationOnly": true,
"composite": true,
"skipLibCheck": true
}
Expand Down
10 changes: 5 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"references": [
{ "path": "packages/conform-dom" },
{ "path": "packages/conform-yup" },
{ "path": "packages/conform-zod" },
{ "path": "packages/conform-react" },
{ "path": "packages/conform-validitystate" }
{ "path": "./packages/conform-dom" },
{ "path": "./packages/conform-yup" },
{ "path": "./packages/conform-zod" },
{ "path": "./packages/conform-react" },
{ "path": "./packages/conform-validitystate" }
],
"files": []
}

0 comments on commit c841225

Please sign in to comment.