microsoft / microsoft/TypeChat
TypeChat JSON Validator Incorrectly Rejects Valid Enums
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.7k
- Forks
- 414
- Avg merge
- 3h 8m
- Merged PRs (30d)
- 3
Description
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 !
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the validator failure with the provided CURRENCY enum and JSON value "EUR", then compare it with the working union-type example. Review the validator entry point and existing validation tests; done means valid enum members are accepted while invalid values remain rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100