ajv-validator / ajv-validator/ajv
Enum type allows no overlap with typescript type
Open
enhancement
typescript
- Dominant language
- TypeScript
- Stars
- 14.8k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
**What version of Ajv are you using? Does the issue happen if you use the latest version?**
8.19.2
IMO this is not fine:
```javascript
import Ajv2020 from 'ajv/dist/2020';
type AOrBType = 'a' | 'b';
const aOrBSchema: JSONSchemaType = {
type: 'string',
enum: ['FOO'],
};
```
The validator never produces a value that is truly `AOrBType`. However, there's no error with this definition. I think there should be.
Contributor guide
Assessment
This issue has not been assessed yet.