Skip to content

Commit f9a34b1

Browse files
JoviDeCroockclaude
andcommitted
docs: Add TypeScript note for Symbol.dispose in Signals models
Users calling model[Symbol.dispose]() directly need ESNext.Disposable in their tsconfig lib. The library typings themselves no longer require it (fixed in preactjs/signals#911), but the symbol still needs to be typed when referenced in app code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 385daf5 commit f9a34b1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

content/en/guide/v10/signals.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ todoList.addTodo('Walk the dog');
591591
todoList[Symbol.dispose]();
592592
```
593593

594+
> **TypeScript:** If you call `model[Symbol.dispose]()` directly, add `"ESNext.Disposable"` (or `"ESNext"`) to the `lib` array in your `tsconfig.json` so that `Symbol.dispose` is typed.
595+
594596
### Recommended Patterns
595597

596598
#### Explicit ReadonlySignal Pattern
@@ -808,6 +810,8 @@ console.log(counter.doubled.value); // 12
808810
counter[Symbol.dispose]();
809811
```
810812

813+
> **TypeScript:** Calling `model[Symbol.dispose]()` requires `"ESNext.Disposable"` (or `"ESNext"`) in your `tsconfig.json` `lib` array.
814+
811815
### action(fn)
812816

813817
The `action(fn)` function wraps a function to run in a batched and untracked context. This is useful when you need to create standalone actions outside of a model:

0 commit comments

Comments
 (0)