# Zero-effort type safety

DevFeed: [Zero-effort type safety](<https://devfeed.tech/articles/zero-effort-type-safety-3130.md>)

Original publisher: [Read original article](<https://svelte.dev/blog/zero-config-type-safety>)

Author: Simon Holthausen

Published: 2023-03-09T00:00:00Z

Content type: article

Language: en

Sources: [Svelte blog](<https://devfeed.tech/sources/svelte-blog.md>)

Topics: [Svelte](<https://devfeed.tech/topics/svelte.md>), [TypeScript](<https://devfeed.tech/topics/typescript.md>), [Visual Studio Code](<https://devfeed.tech/topics/visual-studio-code.md>), [Extension](<https://devfeed.tech/topics/extension.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Routing (disambiguation)](<https://devfeed.tech/topics/routing.md>)

Tags: [cli](<https://devfeed.tech/tags/cli.md>), [errors](<https://devfeed.tech/tags/errors.md>), [extension](<https://devfeed.tech/tags/extension.md>), [framework](<https://devfeed.tech/tags/framework.md>), [routing](<https://devfeed.tech/tags/routing.md>), [svelte](<https://devfeed.tech/tags/svelte.md>), [typescript](<https://devfeed.tech/tags/typescript.md>), [upgrade](<https://devfeed.tech/tags/upgrade.md>), [vscode](<https://devfeed.tech/tags/vscode.md>)

## AI overview

SvelteKit can now automatically generate type information for page data, route parameters, server functions, and universal functions, reducing the need for manual TypeScript annotations. The feature is available through the latest Svelte extension for VSCode, compatible editor extensions that support the Language Server Protocol and TypeScript plugins, and the latest svelte-check CLI diagnostics tool.

## Source excerpt

By sprinkling type annotations into your SvelteKit apps, you can get full type safety across the network -- the data in your page has a type that's inferred from the return values of the load functions that generated that data, without you having to explicitly declare anything. It's one of those things that you come to wonder how you ever lived without. But what if we didn't even need the annotations? Since load and data are part of the framework, can't the framework type them for us? This is, after all, what computers are for -- doing the boring bits so we can focus on the creative stuff. As of today, yes: it can. If you're using VSCode, just upgrade the Svelte extension to the latest version, and you'll never have to annotate your load functions or data props again. Extensions for other editors can also use this feature, as long as they support the Language Server Protocol and TypeScript plugins. It even works with the latest version of our CLI diagnostics tool svelte-check! Before we dive in, let's recap how type safety works in SvelteKit. Generated types In SvelteKit, you get the data for a page in a load function. You could type the event by using ServerLoadEvent from @sveltejs/kit: src/routes/blog/[slug]/+page.server import type { interface ServerLoadEvent<Params extends LayoutParams<"/"> = Record<string, string>, ParentData extends Record<string, any> = Record<string, any>, RouteId extends RouteId | null = string | null> reference ServerLoadEvent } from '@sveltejs/kit'; export async function function load(event: ServerLoadEvent): Promise<{ post: string; }>load(event: ServerLoadEvent<Record<string, string>, Record<string, any>, string | null>event: interface ServerLoadEvent<Params extends LayoutParams<"/"> = Record<string, string>, ParentData extends Record<string, any> = Record<string, any>, RouteId extends RouteId | null = string | null> reference ServerLoadEvent) { return { post: stringpost: await const database: { getPost(slug: string | undefined): Promise<s