ajv-validator / ajv-validator/ajv

Enum type allows no overlap with typescript type

Open
#2,179 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.