Skip to content

Commit a6bf91c

Browse files
authored
docs: add file annotations to examples that benefit from ts toggle (#11058)
1 parent de27832 commit a6bf91c

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

documentation/docs/02-template-syntax/01-svelte-components.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Total: {total}
177177
It is important to note that the reactive blocks are ordered via simple static analysis at compile time, and all the compiler looks at are the variables that are assigned to and used within the block itself, not in any functions called by them. This means that `yDependent` will not be updated when `x` is updated in the following example:
178178

179179
```svelte
180+
<!--- file: App.svelte --->
180181
<script>
181182
let x = 0;
182183
let y = 0;

documentation/docs/02-template-syntax/05-element-directives.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ If the `on:` directive is used without a value, the component will _forward_ the
7474
It's possible to have multiple event listeners for the same event:
7575

7676
```svelte
77+
<!--- file: App.svelte --->
7778
<script>
7879
let counter = 0;
7980
function increment() {
@@ -284,6 +285,7 @@ bind:group={variable}
284285
Inputs that work together can use `bind:group`.
285286

286287
```svelte
288+
<!--- file: App.svelte --->
287289
<script>
288290
let tortilla = 'Plain';
289291
@@ -315,6 +317,7 @@ bind:this={dom_node}
315317
To get a reference to a DOM node, use `bind:this`.
316318

317319
```svelte
320+
<!--- file: App.svelte --->
318321
<script>
319322
import { onMount } from 'svelte';
320323
@@ -420,6 +423,7 @@ action = (node: HTMLElement, parameters: any) => {
420423
Actions are functions that are called when an element is created. They can return an object with a `destroy` method that is called after the element is unmounted:
421424

422425
```svelte
426+
<!--- file: App.svelte --->
423427
<script>
424428
/** @type {import('svelte/action').Action} */
425429
function foo(node) {
@@ -441,6 +445,7 @@ An action can have a parameter. If the returned value has an `update` method, it
441445
> Don't worry about the fact 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.
442446
443447
```svelte
448+
<!--- file: App.svelte --->
444449
<script>
445450
export let bar;
446451
@@ -558,6 +563,7 @@ The `t` argument passed to `css` is a value between `0` and `1` after the `easin
558563
The function is called repeatedly _before_ the transition begins, with different `t` and `u` arguments.
559564

560565
```svelte
566+
<!--- file: App.svelte --->
561567
<script>
562568
import { elasticOut } from 'svelte/easing';
563569

documentation/docs/02-template-syntax/07-special-elements.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ The `<svelte:self>` element allows a component to include itself, recursively.
153153
It cannot appear at the top level of your markup; it must be inside an if or each block or passed to a component's slot to prevent an infinite loop.
154154

155155
```svelte
156+
<!--- file: App.svelte --->
156157
<script>
157158
/** @type {number} */
158159
export let count;
@@ -219,6 +220,7 @@ The `<svelte:window>` element allows you to add event listeners to the `window`
219220
Unlike `<svelte:self>`, this element may only appear at the top level of your component and must never be inside a block or element.
220221

221222
```svelte
223+
<!--- file: App.svelte --->
222224
<script>
223225
/** @param {KeyboardEvent} event */
224226
function handleKeydown(event) {

documentation/docs/03-runtime/07-svelte-action.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: svelte/action
55
Actions are functions that are called when an element is created. They can return an object with a `destroy` method that is called after the element is unmounted:
66

77
```svelte
8+
<!--- file: App.svelte --->
89
<script>
910
/** @type {import('svelte/action').Action} */
1011
function foo(node) {
@@ -26,6 +27,7 @@ An action can have a parameter. If the returned value has an `update` method, it
2627
> 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.
2728
2829
```svelte
30+
<!--- file: App.svelte --->
2931
<script>
3032
/** @type {string} */
3133
export let bar;
@@ -54,6 +56,7 @@ An action can have a parameter. If the returned value has an `update` method, it
5456
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`:
5557

5658
```svelte
59+
<!--- file: App.svelte --->
5760
<script>
5861
/**
5962
* @type {import('svelte/action').Action<HTMLDivElement, { prop: any }, { 'on:emit': (e: CustomEvent<string>) => void }>}

packages/svelte/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Learn more at the [Svelte website](https://svelte.dev), or stop by the [Discord
1414

1515
You can play around with Svelte in the [tutorial](https://learn.svelte.dev/), [examples](https://svelte.dev/examples), and [REPL](https://svelte.dev/repl).
1616

17-
When you're ready to build a full-fledge application, we recommend using [SvelteKit](https://kit.svelte.dev):
17+
When you're ready to build a full-fledged application, we recommend using [SvelteKit](https://kit.svelte.dev):
1818

1919
```bash
2020
npm create svelte@latest my-app

0 commit comments

Comments
 (0)