Describe the bug
Enabling
{
"compilerOptions": { "exactOptionalPropertyTypes": true }
}
in tsconfig.json causes type errors when using optional fields in the schema of a remote form() function
consequently, the type of the parsed data is not correctly inferred, and svelte-check will error with exit code 1
Reproduction
Stackblitz Repro.
TL;DR:
// my.remote.ts
import * as v from 'valibot';
import { form } from '$app/server';
export const createPost = form(
v.object({
// this seems to work fine, but TS and `svelte-check` will complain
myField: v.optional(v.string()),
}),
async ({ myField }) => {
/* ... */
},
)
Logs
│ /src/routes/app/example.remote.ts:5:2
│ Error: No overload matches this call.
│ Overload 1 of 3, '(validate: "unchecked", fn: (data: RemoteFormInput, issue: Record<string | number, any>) =>…
│ Argument of type 'ObjectSchema<{ readonly myField: OptionalSchema<StringSchema<undefined>, undefined>; }, u…
│ Overload 2 of 3, '(validate: StandardSchemaV1<RemoteFormInput, Record<string, any>>, fn: (data: Record<string…
│ Argument of type 'ObjectSchema<{ readonly myField: OptionalSchema<StringSchema<undefined>, undefined>; }, u…
│ The types of '"~standard".types' are incompatible between these types.
│ Type 'StandardTypes<{ myField?: string | undefined; }, { myField?: string | undefined; }> | undefined' …
│ Type 'StandardTypes<{ myField?: string | undefined; }, { myField?: string | undefined; }>' is not ass…
│ Types of property 'input' are incompatible.
│ Type '{ myField?: string | undefined; }' is not assignable to type 'RemoteFormInput'.
│ Property 'myField' is incompatible with index signature.
│ Type 'string | undefined' is not assignable to type 'MaybeArray<string | number | boolean | R…
│ Type 'undefined' is not assignable to type 'MaybeArray<string | number | boolean | RemoteFo…
│ export const signIn = form(
│ v.object({
│ myField: v.optional(v.string()),
│ }),
│ async ({myField}) => {
System Info
Binaries:
Node: 24.11.1
npm: 11.6.2
pnpm: 10.17.1
npmPackages:
@sveltejs/adapter-cloudflare: ^7.2.6 => 7.2.8
@sveltejs/kit: ^2.55.0 => 2.55.0
@sveltejs/vite-plugin-svelte: ^7.0.0 => 7.0.0
svelte: ^5.54.0 => 5.54.0
vite: ^8.0.1 => 8.0.1
Severity
serious, but I can work around it
Additional Information
No response
Describe the bug
Enabling
in
tsconfig.jsoncauses type errors when using optional fields in the schema of a remoteform()functionconsequently, the type of the parsed data is not correctly inferred, and
svelte-checkwill error with exit code1Reproduction
Stackblitz Repro.
TL;DR:
Logs
System Info
Binaries: Node: 24.11.1 npm: 11.6.2 pnpm: 10.17.1 npmPackages: @sveltejs/adapter-cloudflare: ^7.2.6 => 7.2.8 @sveltejs/kit: ^2.55.0 => 2.55.0 @sveltejs/vite-plugin-svelte: ^7.0.0 => 7.0.0 svelte: ^5.54.0 => 5.54.0 vite: ^8.0.1 => 8.0.1Severity
serious, but I can work around it
Additional Information
No response