Skip to content

Commit

Permalink
fix: serialize for bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeiscontent authored and edmundhung committed Apr 29, 2024
1 parent be32a14 commit fbf4de9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/conform-dom/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,11 @@ export function setListState(
});
}

export function serialize<Schema>(
defaultValue: DefaultValue<Schema>,
): FormValue<Schema> {
export function serialize<Schema>(defaultValue: Schema): FormValue<Schema> {
if (isPlainObject(defaultValue)) {
// @ts-expect-error FIXME
return Object.entries(defaultValue).reduce<Record<string, unknown>>(
(result, [key, value]) => {
// @ts-ignore-error FIXME
result[key] = serialize(value);
return result;
},
Expand All @@ -540,16 +537,16 @@ export function serialize<Schema>(
} else if (Array.isArray(defaultValue)) {
// @ts-expect-error FIXME
return defaultValue.map(serialize);
} else if (
// @ts-ignore-error FIXME
defaultValue instanceof Date
) {
} else if (defaultValue instanceof Date) {
// @ts-expect-error FIXME
return defaultValue.toISOString();
} else if (typeof defaultValue === 'boolean') {
// @ts-expect-error FIXME
return defaultValue ? 'on' : undefined;
} else if (typeof defaultValue === 'number') {
} else if (
typeof defaultValue === 'number' ||
typeof defaultValue === 'bigint'
) {
// @ts-expect-error FIXME
return defaultValue.toString();
} else {
Expand Down

0 comments on commit fbf4de9

Please sign in to comment.