Skip to content

Commit 6b9434a

Browse files
JoostKkirjs
authored andcommitted
docs: document that linkedSignal with previous should include type arguments (angular#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 angular#60423 PR Close angular#60857
1 parent c5ca597 commit 6b9434a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

adev/src/content/guide/signals/linked-signal.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ The `source` can be any signal, such as a `computed` or component `input`. When
108108

109109
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.
110110

111+
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`.
112+
111113
## Custom equality comparison
112114

113115
`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:

0 commit comments

Comments
 (0)