From 6b9434a029af34a747a072ea4a23d57b64223326 Mon Sep 17 00:00:00 2001 From: JoostK Date: Sun, 13 Apr 2025 19:12:21 +0200 Subject: [PATCH] docs: document that `linkedSignal` with `previous` should include type arguments (#60857) Due to the cyclic nature of `previous`'s type and the computation's return type, TypeScript isn't able to infer generic type arguments. Closes #60423 PR Close #60857 --- adev/src/content/guide/signals/linked-signal.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adev/src/content/guide/signals/linked-signal.md b/adev/src/content/guide/signals/linked-signal.md index fa2c3a8c915..1b758f605f9 100644 --- a/adev/src/content/guide/signals/linked-signal.md +++ b/adev/src/content/guide/signals/linked-signal.md @@ -108,6 +108,8 @@ The `source` can be any signal, such as a `computed` or component `input`. When The `computation` is a function that receives the new value of `source` and a `previous` object. The `previous` object has two properties— `previous.source` is the previous value of `source`, and `previous.value` is the previous result of the `computation`. You can use these previous values to decide the new result of the computation. +HELPFUL: When using the `previous` parameter, it is necessary to provide the generic type arguments of `linkedSignal` explicitly. The first generic type corresponds with the type of `source` and the second generic type determines the output type of `computation`. + ## Custom equality comparison `linkedSignal`, as any other signal, can be configured with a custom equality function. This function is used by downstream dependencies to determine if that value of the `linkedSignal` (result of a computation) changed: