Microsoft/TypeScript

Enum types are not checked in binary operators

Open

#3845 aperta il 13 lug 2015

Vedi su GitHub
 (5 commenti) (0 reazioni) (0 assegnatari)TypeScript (6726 fork)batch import
Breaking ChangeBugDomain: enumHelp Wanted

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

I ran into this for real while trying to fix a bug in the compiler. We disallow assigning one enum to another if you use the = operator. But we do not disallow it for any of the compound assignment operators. Nor do we disallow for bitwise operators. I think we should disallow all of them.

enum E { }
enum F { }

var e: E;
var f: F;

e = f; // Error
e |= f; // No error
var g = e | f; // No error, g is number

Guida contributor