diff --git a/documentation/docs/20-core-concepts/20-load.md b/documentation/docs/20-core-concepts/20-load.md index 625a6b94040e..e4322c593f7d 100644 --- a/documentation/docs/20-core-concepts/20-load.md +++ b/documentation/docs/20-core-concepts/20-load.md @@ -271,7 +271,7 @@ export async function load({ cookies }) { Both server-only and shared `load` functions have access to a `setHeaders` function that, when running on the server, can set headers for the response. (When running in the browser, `setHeaders` has no effect.) This is useful if you want the page to be cached, for example: ```js -// @errors: 2322 +// @errors: 2322 1360 /// file: src/routes/products/+page.js /** @type {import('./$types').PageLoad} */ export async function load({ fetch, setHeaders }) { diff --git a/documentation/docs/30-advanced/20-hooks.md b/documentation/docs/30-advanced/20-hooks.md index 6940785b5646..9c4b25441e20 100644 --- a/documentation/docs/30-advanced/20-hooks.md +++ b/documentation/docs/30-advanced/20-hooks.md @@ -157,7 +157,7 @@ declare namespace App { ```js /// file: src/hooks.server.js -// @errors: 2322 2571 2339 +// @errors: 2322 1360 2571 2339 // @filename: ambient.d.ts const Sentry: any; @@ -177,7 +177,7 @@ export function handleError({ error, event }) { ```js /// file: src/hooks.client.js -// @errors: 2322 2571 2339 +// @errors: 2322 1360 2571 2339 // @filename: ambient.d.ts const Sentry: any; diff --git a/documentation/docs/30-advanced/25-errors.md b/documentation/docs/30-advanced/25-errors.md index 642acc63f692..651be8897d5f 100644 --- a/documentation/docs/30-advanced/25-errors.md +++ b/documentation/docs/30-advanced/25-errors.md @@ -81,7 +81,7 @@ Unexpected errors will go through the [`handleError`](/docs/hooks#shared-hooks-h ```js /// file: src/hooks.server.js -// @errors: 2322 2571 2339 +// @errors: 2322 1360 2571 2339 // @filename: ambient.d.ts const Sentry: any; diff --git a/documentation/docs/50-reference/40-types.md b/documentation/docs/50-reference/40-types.md index 8e82becfb0c0..8ce147fc1fa4 100644 --- a/documentation/docs/50-reference/40-types.md +++ b/documentation/docs/50-reference/40-types.md @@ -20,7 +20,7 @@ The `RequestHandler` and `Load` types both accept a `Params` argument allowing y ```js /// file: src/routes/[foo]/[bar]/[baz]/+page.server.js -// @errors: 2355 2322 +// @errors: 2355 2322 1360 /** @type {import('@sveltejs/kit').RequestHandler<{ * foo: string; * bar: string; diff --git a/sites/kit.svelte.dev/src/lib/docs/server/index.js b/sites/kit.svelte.dev/src/lib/docs/server/index.js index 0c0de8782d10..94b774d9febe 100644 --- a/sites/kit.svelte.dev/src/lib/docs/server/index.js +++ b/sites/kit.svelte.dev/src/lib/docs/server/index.js @@ -463,11 +463,12 @@ function convert_to_ts(js_code, indent = '', offset = '') { code.overwrite( node.getStart(), node.name.getEnd(), - `${is_export ? 'export ' : ''}const ${node.name.getText()}: ${name} = ${ + `${is_export ? 'export ' : ''}const ${node.name.getText()} = (${ is_async ? 'async ' : '' }` ); code.appendLeft(node.body.getStart(), '=> '); + code.appendLeft(node.body.getEnd(), `) satisfies ${name};`); modified = true; } else if ( diff --git a/sites/kit.svelte.dev/src/lib/docs/server/index.spec.js b/sites/kit.svelte.dev/src/lib/docs/server/index.spec.js index d8684b794228..7c40bcd7fda5 100644 --- a/sites/kit.svelte.dev/src/lib/docs/server/index.spec.js +++ b/sites/kit.svelte.dev/src/lib/docs/server/index.spec.js @@ -59,10 +59,10 @@ export function GET(event) { \`\`\`generated-ts // @errors: 2461 /// file: src/routes/what-is-my-user-agent/+server.ts -import type { RequestHandler } from './$types'; import { json } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; -export const GET: RequestHandler = (event) => { +export const GET = ((event) => { // log all headers console.log(...event.request.headers); @@ -70,7 +70,7 @@ export const GET: RequestHandler = (event) => { // retrieve a specific header userAgent: event.request.headers.get('user-agent') }); -} +}) satisfies RequestHandler; \`\`\` etc etc