TypeScript · Senior · Question 75 of 75
Why is it risky to type an API client with generics alone, like get<T>(url): Promise<T>?
- ✓Correct answer: The generic is an unchecked assertion - any
Tcompiles, even if the server returns something else - 2Generics make requests slower
- 3
Promise<T>can't be awaited
Explanation
Generate types from an OpenAPI schema or validate responses with a schema so the declared type matches reality.