V
V
Vitaly2018-03-01 19:20:00
typescript
Vitaly, 2018-03-01 19:20:00

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

1 answer(s)
S
Stanislav Makarov, 2018-03-02
@Nipheris

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 question

Ask a Question

731 491 924 answers to any question