TypeScript Svelte
SveltePageDataProps Type$props()+page.svelteUsage sectionSvelteChildrenProps Type$props()Usage sectionSveltePageLayoutProps Type$props()+layout.svelteUsage section.md filesmdsvex is not a requirement but if you do use it, then this definition will certainly help to process
5.16.02.15.0
npm add -D @best-skn/svelte-types #or yarn add -D @best-skn/svelte-types #or pnpm add -D @best-skn/svelte-types #or bun add -D @best-skn/svelte-types
types in the root location of your project, and create a file called svelte.d.ts, then do thisimport "@best-skn/svelte-types";
tsconfig.json if includes property has **/*.ts, **/*.tsx, **/*.svelte otherwise the type definition file may not workSveltePageDataProps Type:SveltePageDataProps inside +page.svelte like this//* `+page.svelte` <script lang="ts"> import type { SveltePageDataProps } from "svelte"; import type { PageServerData } from "./$types"; let { data }: SveltePageDataProps<PageServerData> = $props(); </script>
SvelteChildrenProps Type:SvelteChildrenProps inside svelte components containing child components<script lang="ts"> import type { SvelteChildrenProps } from "svelte"; let { children }: SvelteChildrenProps = $props(); </script> <div> {@render children()} </div>
SveltePageLayoutProps Type:SveltePageLayoutProps inside +layout.svelte like this//* `+layout.svelte` <script lang="ts"> import type { SveltePageLayoutProps } from "svelte"; let { children, data, row }: SveltePageLayoutProps<unknown> = $props(); </script> <div> <main> {@render children()} </main> </div>
Prodipta Das Logno & 🧛♀️Atoshi Sarker Prithula: The two most special ladies of my life. My best wishes will always be with you two. May you two always be happy.My Parents: The greatest treasures of my life ever.
Copyright (C) 2024 SKN Shukhan
Licensed under the MIT License