You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It doesn't look like there is a way to do what I want to do, hence the feature request.
Code
declareenumFoods{CHERRY='CHERRY',LETTUCE='LETTUCE',JERKY='JERKY'}declareabstractclassForceFoods{staticfood : Foods}exportclassMyFoodsimplementsForceFoods{staticfood=Foods.CHERRY;// if I omit this line, tsc will not complain}
Expected behavior:
I was hoping tsc could enforce static properties to be defined
Actual behavior:
I don't currently believe tsc can enforce static properties
The text was updated successfully, but these errors were encountered:
Now that we have --strictPropertyInitialization and ! operator for asserting definite assignment, we should consider making an uninitialized static property an error.
That does not solve your problem thought.. it will give you an error on ForceFoods as well as on MyFoods. I think you are looking for #14600 for abstract static properties/methods.
I added this question on SO:
is there a way to enforce static class properties? https://stackoverflow.com/questions/48813814/enforce-static-member-in-class-using-enum
It doesn't look like there is a way to do what I want to do, hence the feature request.
Code
Expected behavior:
I was hoping tsc could enforce static properties to be defined
Actual behavior:
I don't currently believe tsc can enforce static properties
The text was updated successfully, but these errors were encountered: