Skip to content

Commit

Permalink
chore: fix docs (#14538)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Dec 3, 2024
1 parent 3d9122f commit 4c4f18b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions documentation/docs/98-reference/.generated/client-warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Given a case like this...
You can fix this by separating it into two statements:

```js
let object = { array: [0] };
// ---cut---
function add() {
object.array ??= [];
object.array.push(object.array.length);
Expand Down Expand Up @@ -131,16 +133,22 @@ In runes mode, effects and deriveds re-run when there are changes to the values
Often, the result is the same — for example these can be considered equivalent:

```js
let a = 1, b = 2, sum = 3;
// ---cut---
$: sum = a + b;
```

```js
let a = 1, b = 2;
// ---cut---
const sum = $derived(a + b);
```

In some cases — such as the one that triggered the above warning — they are _not_ the same:

```js
let a = 1, b = 2, sum = 3;
// ---cut---
const add = () => a + b;

// the compiler can't 'see' that `sum` depends on `a` and `b`, but
Expand Down
8 changes: 8 additions & 0 deletions packages/svelte/messages/client-warnings/warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Given a case like this...
You can fix this by separating it into two statements:

```js
let object = { array: [0] };
// ---cut---
function add() {
object.array ??= [];
object.array.push(object.array.length);
Expand Down Expand Up @@ -95,16 +97,22 @@ In runes mode, effects and deriveds re-run when there are changes to the values
Often, the result is the same — for example these can be considered equivalent:
```js
let a = 1, b = 2, sum = 3;
// ---cut---
$: sum = a + b;
```
```js
let a = 1, b = 2;
// ---cut---
const sum = $derived(a + b);
```
In some cases — such as the one that triggered the above warning — they are _not_ the same:
```js
let a = 1, b = 2, sum = 3;
// ---cut---
const add = () => a + b;

// the compiler can't 'see' that `sum` depends on `a` and `b`, but
Expand Down

0 comments on commit 4c4f18b

Please sign in to comment.