NG.VII · Angular 22 practice question
When a developer supplies a parse function to httpResource that returns a validated User object, how is the TypeScript type of the resource's value determined?
Check answer and explanation
Correct answer: It is inferred from the return type of the parse function.
Explanation
When using the parse option, the type of the resource's value is inferred from the return type of the parse function.
Common trap
Providing a typed parse function eliminates the need for manual casting in templates. You do not need a redundant generic type argument because httpResource derives the resource value type from parse.
Source: Angular docs: Reactive data fetching with `httpResource` — Response parsing and validation
Checked against the cited text on 2026-11-25.