Skip to content

Commit 47deef9

Browse files
Sync svelte docs (#1395)
sync svelte docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com>
1 parent 36bee82 commit 47deef9

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

apps/svelte.dev/content/docs/svelte/07-misc/03-typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ If you're using tools like Rollup or Webpack instead, install their respective S
8484

8585
When using TypeScript, make sure your `tsconfig.json` is setup correctly.
8686

87-
- Use a [`target`](https://www.typescriptlang.org/tsconfig/#target) of at least `ES2022`, or a `target` of at least `ES2015` alongside [`useDefineForClassFields`](https://www.typescriptlang.org/tsconfig/#useDefineForClassFields). This ensures that rune declarations on class fields are not messed with, which would break the Svelte compiler
87+
- Use a [`target`](https://www.typescriptlang.org/tsconfig/#target) of at least `ES2015` so classes are not compiled to functions
8888
- Set [`verbatimModuleSyntax`](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) to `true` so that imports are left as-is
8989
- Set [`isolatedModules`](https://www.typescriptlang.org/tsconfig/#isolatedModules) to `true` so that each file is looked at in isolation. TypeScript has a few features which require cross-file analysis and compilation, which the Svelte compiler and tooling like Vite don't do.
9090

apps/svelte.dev/content/docs/svelte/98-reference/.generated/client-errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ Effect cannot be created inside a `$derived` value that was not itself created i
7474
Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops
7575
```
7676

77+
### get_abort_signal_outside_reaction
78+
79+
```
80+
`getAbortSignal()` can only be called inside an effect or derived
81+
```
82+
7783
### hydration_failed
7884

7985
```

apps/svelte.dev/content/docs/svelte/98-reference/20-svelte.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
createEventDispatcher,
1616
createRawSnippet,
1717
flushSync,
18+
getAbortSignal,
1819
getAllContexts,
1920
getContext,
2021
hasContext,
@@ -291,6 +292,40 @@ function flushSync<T = void>(fn?: (() => T) | undefined): T;
291292

292293

293294

295+
## getAbortSignal
296+
297+
Returns an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) that aborts when the current [derived](/docs/svelte/$derived) or [effect](/docs/svelte/$effect) re-runs or is destroyed.
298+
299+
Must be called while a derived or effect is running.
300+
301+
```svelte
302+
<script>
303+
import { getAbortSignal } from 'svelte';
304+
305+
let { id } = $props();
306+
307+
async function getData(id) {
308+
const response = await fetch(`/items/${id}`, {
309+
signal: getAbortSignal()
310+
});
311+
312+
return await response.json();
313+
}
314+
315+
const data = $derived(await getData(id));
316+
</script>
317+
```
318+
319+
<div class="ts-block">
320+
321+
```dts
322+
function getAbortSignal(): AbortSignal;
323+
```
324+
325+
</div>
326+
327+
328+
294329
## getAllContexts
295330

296331
Retrieves the whole context map that belongs to the closest parent component.

apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-compiler.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ namespace AST {
208208
instance: Script | null;
209209
/** The parsed `<script module>` element, if exists */
210210
module: Script | null;
211+
/** Comments found in <script> and {expressions} */
212+
comments: JSComment[];
211213
}
212214
213215
export interface SvelteOptions {
@@ -554,6 +556,17 @@ namespace AST {
554556
attributes: Attribute[];
555557
}
556558
559+
export interface JSComment {
560+
type: 'Line' | 'Block';
561+
value: string;
562+
start: number;
563+
end: number;
564+
loc: {
565+
start: { line: number; column: number };
566+
end: { line: number; column: number };
567+
};
568+
}
569+
557570
export type AttributeLike =
558571
| Attribute
559572
| SpreadAttribute
@@ -617,7 +630,8 @@ namespace AST {
617630
| Node
618631
| TemplateNode
619632
| AST.Fragment
620-
| _CSS.Node;
633+
| _CSS.Node
634+
| Script;
621635
622636
export type { _CSS as CSS };
623637
}

apps/svelte.dev/content/docs/svelte/98-reference/30-runtime-errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ Effect cannot be created inside a `$derived` value that was not itself created i
8181
Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops
8282
```
8383

84+
### get_abort_signal_outside_reaction
85+
86+
```
87+
`getAbortSignal()` can only be called inside an effect or derived
88+
```
89+
8490
### hydration_failed
8591

8692
```

0 commit comments

Comments
 (0)