You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Add TypeScript note for Symbol.dispose in models (#1383)
* 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.
* docs: Mirror Symbol.dispose TypeScript note in v11
Copy file name to clipboardExpand all lines: content/en/guide/v10/signals.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -591,6 +591,8 @@ todoList.addTodo('Walk the dog');
591
591
todoList[Symbol.dispose]();
592
592
```
593
593
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.
> **TypeScript:** Calling `model[Symbol.dispose]()` requires `"ESNext.Disposable"` (or `"ESNext"`) in your `tsconfig.json``lib` array.
814
+
811
815
### action(fn)
812
816
813
817
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:
Copy file name to clipboardExpand all lines: content/en/guide/v11/signals.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -591,6 +591,8 @@ todoList.addTodo('Walk the dog');
591
591
todoList[Symbol.dispose]();
592
592
```
593
593
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.
> **TypeScript:** Calling `model[Symbol.dispose]()` requires `"ESNext.Disposable"` (or `"ESNext"`) in your `tsconfig.json``lib` array.
814
+
811
815
### action(fn)
812
816
813
817
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