TypeScript · Senior · Question 75 of 75

Why is it risky to type an API client with generics alone, like get<T>(url): Promise<T>?

Explanation

Generate types from an OpenAPI schema or validate responses with a schema so the declared type matches reality.

Further reading

Problem with a question

TypeScript · Senior · question 75

Test yourself

Take the TypeScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz