当为变量分配与其枚举类型不兼容的值时,是否可能让tslint抛出错误?
例如:
export enum Gender {
male = 1,
female = 2
}
export class User {
id: number;
gender: Gender;
}
var user = new User();
user.gender = Gender.Male; // OK
user.gender = 3; // Currently is OK, desired result: TYPE ERROR
if (user.gender === Gender.Male) {} // OK
if (user.gender === 3) {} // Currently is OK, desired result: TYPE ERROR