rbxts-flamework / core

Flamework is an extensible game framework. It requires typescript and offers many useful features.
MIT License
101 stars 8 forks source link

Type guard generation fails on non literal enums #59

Closed Fireboltofdeath closed 1 year ago

Fireboltofdeath commented 2 years ago
enum A {}

Flamework.createGuard<A>();
Fireboltofdeath commented 2 years ago

Closing this for now as it's not clear how these guards should be generated.

Non literal enums have no details about values of individual members and whether empty enums should be permissive or restrictive is not very clear. TypeScript appears to allow any numbers in the latter case but I don't think this behavior makes sense for any of Flamework's usecases.

Fireboltofdeath commented 1 year ago

In the case of const enums, TypeScript does calculate the values for this although it's still represented as a "namespace enum" which needs to be handled separately from normal enums.