-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Type inference for advanced linkedSignal signature #60423
Copy link
Copy link
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: reactivityWork related to fine-grained reactivity in the core frameworkWork related to fine-grained reactivity in the core frameworkcross-cutting: signals
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
The signature of linkedSignal that takes an object with source and computation properties does not allow for proper type inference, given the cyclic nature of the previous argument of the computation. Even though previous.value uses NoInfer to block TypeScript from picking up inferences from this position, TypeScript is still unable to infer type arguments if they are omitted:
const user = signal('Joost');
const linked = linkedSignal({
source: user,
computation: (user) => user.length,
});Here, linked is inferred as WritableSignal<unknown> instead of WritableSignal<number>.
Please provide a link to a minimal reproduction of the bug
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: reactivityWork related to fine-grained reactivity in the core frameworkWork related to fine-grained reactivity in the core frameworkcross-cutting: signals