Skip to content
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

fix: data from $props does not need type #2580

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,38 @@ const defaultScriptTemplate = `
/** @type {import('./$types').LayoutData} */
export let data;
</script>

<slot />
`;

const tsSv5ScriptTemplate = `
<script lang="ts">
import type { Snippet } from 'svelte';
import type { LayoutData } from './$types';
let { data }: LayoutData = $props();

let { data, children }: { data: LayoutData, children: Snippet } = $props();
</script>

{@render children()}
`;

const tsScriptTemplate = `
<script lang="ts">
import type { LayoutData } from './$types';

export let data: LayoutData;
</script>

<slot />
`;

const jsSv5ScriptTemplate = `
<script>
/** @type {import('./$types').LayoutData} */
let { data } = $props();
/** @type {{ data: import('./$types').LayoutData, children: import('svelte').Snippet }} */
let { data, children } = $props();
</script>

{@render children()}
`;

const scriptTemplate: ReadonlyMap<ProjectType, string> = new Map([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ const defaultScriptTemplate = `
const tsSv5ScriptTemplate = `
<script lang="ts">
import type { PageData } from './$types';
let { data }: PageData = $props();
let { data }: { data: PageData } = $props();
</script>
`;

const tsScriptTemplate = `
<script lang="ts">
import type { PageData } from './$types';
export let data: PageData;
</script>
`;

const jsSv5ScriptTemplate = `
<script>
/** @type {import('./$types').PageData} */
/** @type {{ data: import('./$types').PageData }} */
let { data } = $props();
</script>
`;
Expand Down