TypeScript · Junior · Question 62 of 75
How do you call a generic function with an explicit type argument?
const value = parse<User>(json);- ✓Correct answer: Pass the type in angle brackets after the function name
- 2Pass the type as a normal argument
- 3Use
parse as User(json)
Explanation
Usually TypeScript infers type arguments from the values. Explicit arguments help when there is nothing to infer from.