Answer the question
In order to leave comments, you need to log in
How to disable automatic casting of number to enum?
I am writing a node.js application using TS. I noticed that I can assign a number to a variable of enum type, although it should require an explicit cast. What compiler option is responsible for this?
Answer the question
In order to leave comments, you need to log in
No, it's By Design.
https://github.com/Microsoft/TypeScript/issues/6131
It's to allow patterns such as n = n + 1.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question