-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type instantiation is excessively deep and possibly infinite with componentized fields #463
Comments
I can't see any LoginForm.svelte in the example link? |
@ciscoheat I'm sorry - I guess sveltelab didn't save my changes earlier :( Here is a corrected repro link: https://www.sveltelab.dev/fh9ym08604bfrxv If you click into LoginForm.svelte now, the issue will appear Again, this might be a limitation of Typescript (or my knowledge thereof) but I am very thankful that you would take a look -- to me, extending the componentization even further was the natural thing to do. |
I see now, I should have looked closer at the code example. You need I did manage to remove the error once locally, so try updating to latest typescript (and maybe latest svelte 5) and maybe it will work. |
I have the same problem |
FWIW I've just upgraded to svelte5 and all my other packages to latest and I can no longer reproduce the original issue. |
This still happens to me with Svelte 5: radio-item.svelte<script lang="ts" generics="T extends Record<string, unknown>">
import type { FormPathLeaves, SuperForm } from "sveltekit-superforms";
import RadioInput from "./radio-input.svelte";
interface Props {
superForm: SuperForm<T>;
field: FormPathLeaves<T>;
value: string | number;
}
let { superForm, field, value }: Props = $props();
</script>
<RadioInput {superForm} {field} {value}></RadioInput> radio-input.svelte<script lang="ts" generics="T extends Record<string, unknown>">
import type { FormPathLeaves } from "sveltekit-superforms";
import { fieldProxy, type SuperForm } from "sveltekit-superforms";
interface Props {
superForm: SuperForm<T>;
field: FormPathLeaves<T>;
value: string | number;
}
let { superForm, field, value }: Props = $props();
const groupValue = fieldProxy(superForm, field);
let id = $derived(`${value}-${field}`);
</script>
<input {id} type="radio" class="peer sr-only" name={field} {value} bind:group={$groupValue} /> |
You're right, I'm still seeing this :( |
Description
I'm trying to even further componentize the approach in the componentization guide, by allowing users to pass an array of the FormPathLeaves to render the form fields.
However, I'm seeing a TS error, "Type instantiation is excessively deep and possibly infinite" when trying to use FormPathLeaves as a variable, rather than hardcoding it. You can see three parallel approaches in the below snippet.
This may very well be some limitation of my typescript knowledge... but is this just not intrinsically possible? Should I be listing out the paths with a different type annotation?
If applicable, a MRE
See this example, which has the error on Sveltelab when you view the LoginForm.svelte file: EXAMPLE
The text was updated successfully, but these errors were encountered: