TypeScript · Senior · Question 68 of 75

Why should a public library avoid enum in its API?

Explanation

A union of string literals (with an as const object if you need runtime values) is erasable and friendlier to consumers.

Further reading

Problem with a question

TypeScript · Senior · question 68

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