TypeScript · Senior · Question 14 of 75

In what order should function overloads be written?

Explanation

If a general overload (x: any) comes first, it "captures" every call and the specific signatures become useless. Another tip: don't write overloads that differ only in the last parameter - use an optional parameter instead.

Further reading

Problem with a question

TypeScript · Senior · question 14

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