Microsoft/TypeScript

Enum types are not checked in binary operators

Open

#3 845 ouverte le 13 juil. 2015

Voir sur GitHub
 (5 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
Breaking ChangeBugDomain: enumHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

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

Guide contributeur