Skip to content

Commit b6cd496

Browse files
AkifumiSatoakfm.sato
andauthored
Fix conform type, vitest deps update, commit hooks/turborepo update (#481)
* fix: vitest deps, pre-commit * refactor: turborepo ui * fix: `useLocationForm` type strict check * changesets add --------- Co-authored-by: akfm.sato <01047245@CF0286.local>
1 parent 4bb0c3b commit b6cd496

File tree

9 files changed

+32
-28
lines changed

9 files changed

+32
-28
lines changed

.changeset/fluffy-shirts-notice.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@location-state/conform": patch
3+
"@location-state/core": patch
4+
---
5+
6+
Fix @location-state/conform types: strict check.

.husky/pre-commit

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
31

42
pnpm exec lint-staged
53
pnpm run commit-check

apps/example-next-conform/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"lib": ["dom", "dom.iterable", "esnext"],
55
"allowJs": true,
66
"skipLibCheck": true,
7-
"strict": false,
7+
"strict": true,
88
"forceConsistentCasingInFileNames": true,
99
"noEmit": true,
1010
"esModuleInterop": true,

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"playwright": "1.46.1",
3939
"tsup": "8.2.4",
4040
"turbo": "2.0.14",
41-
"typescript": "5.5.4",
42-
"vitest": "2.0.5"
41+
"typescript": "5.5.4"
4342
}
4443
}

packages/location-state-conform/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"@repo/test-utils": "workspace:*",
3939
"@repo/utils": "workspace:*",
4040
"@types/react": "18.3.4",
41-
"react": "18.3.1"
41+
"react": "18.3.1",
42+
"vitest": "2.0.5"
4243
},
4344
"peerDependencies": {
4445
"@conform-to/react": "^1.0.0",

packages/location-state-conform/src/hooks.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getFormProps } from "@conform-to/react";
2+
import type { FormMetadata } from "@conform-to/react";
23
import {
34
type LocationStateDefinition,
45
useLocationGetState,
@@ -19,11 +20,10 @@ import {
1920
import { insertedAt, removedAt, reorderedAt } from "./utils/updated-array";
2021
import { updatedWithPath } from "./utils/updated-object";
2122

22-
type GetFormPropsArgs = Parameters<typeof getFormProps>;
23-
type GetLocationFormPropsReturnWith = ReturnType<typeof getFormProps>;
24-
type GetLocationFormProps = (
25-
...args: GetFormPropsArgs
26-
) => GetLocationFormPropsReturnWith & {
23+
type GetLocationFormProps = <Schema extends Record<string, unknown>, FormError>(
24+
metadata: FormMetadata<Schema, FormError>,
25+
options?: Parameters<typeof getFormProps>[1],
26+
) => ReturnType<typeof getFormProps> & {
2727
onChange: (e: React.ChangeEvent<HTMLFormElement>) => void;
2828
};
2929

@@ -37,12 +37,7 @@ export function useLocationForm<Schema extends Record<string, unknown>>({
3737
>;
3838
idPrefix?: string;
3939
}>
40-
>): [
41-
{
42-
id: string;
43-
},
44-
GetLocationFormProps,
45-
] {
40+
>) {
4641
const locationDefinition: LocationStateDefinition<
4742
DeepPartial<Schema> | undefined
4843
> = {
@@ -58,7 +53,7 @@ export function useLocationForm<Schema extends Record<string, unknown>>({
5853
const formIdSuffix = `location-form-${locationKey}`;
5954
const formId = `${formIdPrefix}-${formIdSuffix}`;
6055

61-
const formRef = useRef<GetFormPropsArgs[0] | null>(null);
56+
const formRef = useRef<FormMetadata | null>(null);
6257
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
6358
useEffect(() => {
6459
if (!locationKey) return;
@@ -77,9 +72,9 @@ export function useLocationForm<Schema extends Record<string, unknown>>({
7772
}
7873
}, [locationKey, formId, getLocationState]);
7974

80-
const getLocationFormProps: GetLocationFormProps = useCallback(
81-
(form, option) => {
82-
formRef.current = form;
75+
const getLocationFormProps = useCallback(
76+
(form, option?) => {
77+
formRef.current = form as FormMetadata;
8378
const { onSubmit: onSubmitOriginal, ...formProps } = getFormProps(
8479
form,
8580
option,
@@ -176,9 +171,9 @@ export function useLocationForm<Schema extends Record<string, unknown>>({
176171
};
177172
},
178173
[getLocationState, setLocationState],
179-
);
174+
) satisfies GetLocationFormProps;
180175

181-
return [{ id: formId }, getLocationFormProps];
176+
return [{ id: formId }, getLocationFormProps] as const;
182177
}
183178

184179
function parseSafe(json: string): { type: string; payload: unknown } {

packages/location-state-core/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"client-only": "0.0.1",
4545
"navigation-api-types": "0.5.1",
4646
"react": "18.3.1",
47-
"uuid": "10.0.0"
47+
"uuid": "10.0.0",
48+
"vitest": "2.0.5"
4849
},
4950
"peerDependencies": {
5051
"react": "^18.2.0"

pnpm-lock.yaml

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://turbo.build/schema.json",
3+
"ui": "tui",
34
"tasks": {
45
"dev": {
56
"cache": false,

0 commit comments

Comments
 (0)