Skip to content

Commit

Permalink
svelte-check fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscoheat committed Aug 13, 2024
1 parent f9d3e1d commit 911d399
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/routes/(v1)/tests/reset-component-2/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script lang="ts">
import { registerSchema } from './schema.js';
import SuperForm from './Form.svelte';
import Form from './Form.svelte';
import TextField from './TextField.svelte';
import { zod } from '$lib/adapters/zod.js';
import type { Infer, SuperForm } from '$lib/index.js';
let visible = $state(true);
let { data } = $props();
Expand All @@ -16,7 +17,7 @@

<button onclick={() => (visible = !visible)}>Toggle</button>

{#snippet msg(message)}
{#snippet msg(message: { status: number; text: string })}
{#if message}
<div
class="status"
Expand All @@ -28,7 +29,7 @@
{/if}
{/snippet}

{#snippet fields(form)}
{#snippet fields(form: SuperForm<Infer<typeof registerSchema>>)}
<TextField type="text" {form} field="name" label="Name" />
<TextField type="text" {form} field="email" label="E-Mail" />
<p>
Expand All @@ -38,14 +39,14 @@

{#if visible}
<!-- SuperForm with dataType 'form' -->
<SuperForm
<Form
action="?/register"
schema={zod(registerSchema)}
data={data.regForm}
invalidateAll={false}
{msg}
{fields}
></SuperForm>
></Form>
{/if}

<style>
Expand Down
12 changes: 8 additions & 4 deletions src/routes/(v1)/tests/reset-component-2/TextField.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<script lang="ts">
import { formFieldProxy } from '$lib/client/index.js';
<script lang="ts" context="module">
type T = Record<string, unknown>;
</script>

<script lang="ts" generics="T extends Record<string, unknown>">
import { formFieldProxy, type FormPathLeaves, type SuperForm } from '$lib/client/index.js';
let _class = '';
export { _class as class };
export let label: string | undefined = undefined;
export let field: string;
export let form;
export let field: FormPathLeaves<T>;
export let form: SuperForm<T>;
const { value, errors } = formFieldProxy(form, field);
</script>
Expand Down

0 comments on commit 911d399

Please sign in to comment.