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

add a SvelteKit namespace for app-level types (#3569) #3670

Merged
merged 14 commits into from
Feb 2, 2022
Prev Previous commit
Next Next commit
link to typescript section
  • Loading branch information
Rich-Harris committed Feb 1, 2022
commit c57837f57fb3a18a7839f7c5bd937e604ef68926
2 changes: 2 additions & 0 deletions documentation/docs/01-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export interface RequestHandler<Output extends Body = Body> {
}
```

> See the [TypeScript](#typescript) section for information on `SvelteKit.Locals` and `SvelteKit.Platform`.

For example, our hypothetical blog page, `/blog/cool-article`, might request data from `/blog/cool-article.json`, which could be represented by a `src/routes/blog/[slug].json.js` endpoint:

```js
Expand Down
4 changes: 3 additions & 1 deletion documentation/docs/03-loading.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A component that defines a page or a layout can export a `load` function that ru

export interface LoadInput<Params extends Record<string, string> = Record<string, string>> {
url: URL;
params: PageParams;
params: Params;
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
session: SvelteKit.Session;
stuff: Partial<SvelteKit.Stuff>;
Expand All @@ -35,6 +35,8 @@ export interface Load<Params = Record<string, string>, Props = Record<string, an
}
```

> See the [TypeScript](#typescript) section for information on `SvelteKit.Session` and `SvelteKit.Stuff`.

Our example blog page might contain a `load` function like the following:

```html
Expand Down
2 changes: 2 additions & 0 deletions documentation/docs/04-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export interface Handle {
}
```

> See the [TypeScript](#typescript) section for information on `SvelteKit.Locals` and `SvelteKit.Platform`.

To add custom data to the request, which is passed to endpoints, populate the `event.locals` object, as shown below.

```js
Expand Down