Skip to content

fix: AsArgs default value type#15681

Draft
paoloricciuti wants to merge 1 commit into
mainfrom
fix-types-of-as-args
Draft

fix: AsArgs default value type#15681
paoloricciuti wants to merge 1 commit into
mainfrom
fix-types-of-as-args

Conversation

@paoloricciuti

Copy link
Copy Markdown
Member

The current types are a bit weird to work with...since it's expecting something if you have a variable that can be null or undefined it will yell at you (even tho it doesn't make sense since undefined is technically an acceptable value).

Furthermore the (string | {}) trick doesn't make sense here where the value can be anything (a number for example).

There's still one issue that I wasn't fully able to solve yet: for checkbox if you have a boolean value TS will complain because boolean is not assignable to true and false which is what the type is expecting (actual strict values, not just boolean).

Do you have any ideas on how to fix this?

@changeset-bot

changeset-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e3b6932

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@henrykrinkle01

Copy link
Copy Markdown
Contributor

I'm glad this is being worked on. It's been bugging me since release.
I hope you can fix the type for the discriminator in a discriminated union schema as well. For example:

const base = z.object({ /* some fields */})

const type1 = base.extend({
    typeId: z.literal(1),
    /* other fields */
})
const type2 = base.extend({
    typeId: z.literal(2),
    /* other fields */
})
const combined = z.discriminatedUnion('typeId',
    [type1, type2]
)

TS doesn't even accept literal values like 1 or 2:

Argument of type '1' is not assignable to parameter of type '"number" | "range"'

@elliott-with-the-longest-name-on-github

Copy link
Copy Markdown
Contributor

@paoloricciuti is this related to #15723, or are they completely different?

@dummdidumm

Copy link
Copy Markdown
Member

Is there something we can add to the type tests? So we don't regress

@teemingc teemingc linked an issue May 18, 2026 that may be closed by this pull request
@teemingc teemingc marked this pull request as draft May 18, 2026 21:27
@teemingc

teemingc commented May 18, 2026

Copy link
Copy Markdown
Member

I think the additional issue mentioned in the PR description is still being worked on so I've changed this to a draft for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote Forms not handling null values

5 participants