diff --git a/documentation/docs/02-template-syntax/05-element-directives.md b/documentation/docs/02-template-syntax/05-element-directives.md
index 0f602bf6ea..e0ac44fe35 100644
--- a/documentation/docs/02-template-syntax/05-element-directives.md
+++ b/documentation/docs/02-template-syntax/05-element-directives.md
@@ -455,6 +455,8 @@ An action can have a parameter. If the returned value has an `update` method, it
```
+Read more in the [`svelte/action`](/docs/svelte-action) page.
+
## transition:_fn_
```svelte
@@ -526,6 +528,10 @@ The function is called repeatedly _before_ the transition begins, with different
/** @type {boolean} */
export let visible;
+ /**
+ * @param {HTMLElement} node
+ * @param {{ delay?: number, duration?: number, easing?: (t: number) => number }} params
+ */
function whoosh(node, params) {
const existingTransform = getComputedStyle(node).transform.replace('none', '');
@@ -548,9 +554,14 @@ A custom transition function can also return a `tick` function, which is called
> If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
```svelte
+
+
+
+```
+
+An action can have a parameter. If the returned value has an `update` method, it will be called immediately after Svelte has applied updates to the markup whenever that parameter changes.
+
+> Don't worry that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
+
+```svelte
+
+
+
+
+```
+
+## Attributes
+
+Sometimes actions emit custom events and apply custom attributes to the element they are applied to. To support this, actions typed with `Action` or `ActionReturn` type can have a last parameter, `Attributes`:
+
+```svelte
+
+
+
+
+```
## Types
diff --git a/documentation/docs/05-misc/02-typescript.md b/documentation/docs/05-misc/02-typescript.md
index da8b3b8f5a..70905f6800 100644
--- a/documentation/docs/05-misc/02-typescript.md
+++ b/documentation/docs/05-misc/02-typescript.md
@@ -2,6 +2,193 @@
title: TypeScript
---
+You can use TypeScript within Svelte components. IDE extensions like the [Svelte VSCode extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) will help you catch errors right in your editor, and [`svelte-check`](https://www.npmjs.com/package/svelte-check) does the same on the command line, which you can integrate into your CI.
+
+## Setup
+
+To use TypeScript within Svelte components, you need to add a preprocessor that will turn TypeScript into JavaScript.
+
+### Using SvelteKit or Vite
+
+The easiest way to get started is scaffolding a new SvelteKit project by typing `npm create svelte@latest`, following the prompts and chosing the TypeScript option.
+
+```ts
+/// file: svelte.config.js
+// @noErrors
+import { vitePreprocess } from '@sveltejs/kit/vite';
+
+const config = {
+ preprocess: vitePreprocess()
+};
+
+export default config;
+```
+
+If you don't need or want all the features SvelteKit has to offer, you can scaffold a Svelte-flavoured Vite project instead by typing `npm create vite@latest` and selecting the `svelte-ts` option.
+
+```ts
+/// file: svelte.config.js
+import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
+
+const config = {
+ preprocess: vitePreprocess()
+};
+
+export default config;
+```
+
+In both cases, a `svelte.config.js` with `vitePreprocess` will be added. Vite/SvelteKit will read from this config file.
+
+### Other build tools
+
+If you're using tools like Rollup or Webpack instead, install their respective Svelte plugins. For Rollup that's [rollup-plugin-svelte](https://github.com/sveltejs/rollup-plugin-svelte) and for Webpack that's [svelte-loader](https://github.com/sveltejs/svelte-loader). For both, you need to install `typescript` and `svelte-preprocess` and add the preprocessor to the plugin config (see the respective READMEs for more info). If you're starting a new project, you can also use the [rollup](https://github.com/sveltejs/template) or [webpack](https://github.com/sveltejs/template-webpack) template to scaffold the setup from a script.
+
+> If you're starting a new project, we recommend using SvelteKit or Vite instead
+
+## `
+```
+
+### Props
+
+Props can be typed directly on the `export let` statement:
+
+```svelte
+
+```
+
+### Slots
+
+Slot and slot prop types are inferred from the types of the slot props passed to them:
+
+```svelte
+
+
+
+
+
+
+
+ {name}
+
+```
+
+### Events
+
+Events can be typed with `createEventDispatcher`:
+
+```svelte
+
+
+
+```
+
+## Enhancing built-in DOM types
+
+Svelte provides a best effort of all the HTML DOM types that exist. Sometimes you may want to use experimental attributes or custom events coming from an action. In these cases, TypeScript will throw a type error, saying that it does not know these types. If it's a non-experimental standard attribute/event, this may very well be a missing typing from our [HTML typings](https://github.com/sveltejs/svelte/blob/master/elements/index.d.ts). In that case, you are welcome to open an issue and/or a PR fixing it.
+
+In case this is a custom or experimental attribute/event, you can enhance the typings like this:
+
+```ts
+/// file: additional-svelte-typings.d.ts
+declare namespace svelteHTML {
+ // enhance elements
+ interface IntrinsicElements {
+ 'my-custom-element': { someattribute: string; 'on:event': (e: CustomEvent) => void };
+ }
+ // enhance attributes
+ interface HTMLAttributes {
+ // If you want to use on:beforeinstallprompt
+ 'on:beforeinstallprompt'?: (event: any) => any;
+ // If you want to use myCustomAttribute={..} (note: all lowercase)
+ mycustomattribute?: any; // You can replace any with something more specific if you like
+ }
+}
+```
+
+Then make sure that `d.ts` file is referenced in your `tsconfig.json`. If it reads something like `"include": ["src/**/*"]` and your `d.ts` file is inside `src`, it should work. You may need to reload for the changes to take effect.
+
+## Experimental advanced typings
+
+A few features are missing from taking full advantage of TypeScript in more advanced use cases like typing that a component implements a certain interface, explicitly typing slots, or using generics. These things are possible using experimental advanced type capabilities. See [this RFC](https://github.com/dummdidumm/rfcs/blob/ts-typedefs-within-svelte-components/text/ts-typing-props-slots-events.md) for more information on how to make use of them.
+
+> The API is experimental and may change at any point
+
+## Limitations
+
+### No TS in markup
+
+You cannot use TypeScript in your template's markup. For example, the following does not work:
+
+```svelte
+
+
+