Open sho31 opened 11 months ago
Do you think type safety is guaranteed with a union type?
Yes. While TypeScript can technically prevent comparisons across different enum types, union types are still type-safe. However, I do see why it's a pain that an enum can't be used with TypeChat.
Hello! I included some enums in my schema, but unfortunately the library seems incompatible with schemas containing enums. My JSON data includes values that should correspond to valid enum keys, but the validator seems to incorrectly rejects these values.
Here is a part of the error and the Currency enum :
Error: Type '"EUR"' is not assignable to type 'CURRENCY'. {... "currency": "EUR", ...}
export enum CURRENCY { USD = 'USD', EUR = 'EUR', GBP = 'GBP', }
That worked using union type like the following :
type CURRENCY = 'USD' | 'EUR' | 'GBP';
Will enums be supported in the future, or my implementation may be wrong ? Do you think type safety is guaranteed with a union type ?
Thank you !