ajv-validator / ajv-validator/ajv
JSONSchemaType requires "required" and "additionalProperties", unless it is oneOf schema
- 主要言語
- TypeScript
- スター
- 14.8k
- フォーク
- 1k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
**What version of Ajv are you using? Does the issue happen if you use the latest version?**
8.0.1, yes
**Ajv options object**
```javascript
{}
```
**Your code**
```typescript
type Test = {
some: string;
other: boolean;
};
const t: JSONSchemaType = {
type: 'object',
properties: {
other: {
type: 'boolean',
},
some: {
type: 'string',
},
},
};
```
**What results did you expect?**
Should be a valid type, instead the compiler throws
`TS2322: Type '{ type: "object"; properties: { other: { type: "boolean"; }; some: { type: "string"; }; }; }' is not assignable to type 'JSONSchemaType'. Type '{ type: "object"; properties: { other: { type: "boolean"; }; some: { type: "string"; }; }; }' is not assignable to type '{ oneOf: readonly JSONSchemaType[]; } & { [keyword: string]: any; $id?: string; $ref?: string; $defs?: { [x: string]: JSONSchemaType; }; definitions?: { ...; }; }'. Property 'oneOf' is missing in type '{ type: "object"; properties: { other: { type: "boolean"; }; some: { type: "string"; }; }; }' but required in type '{ oneOf: readonly JSONSchemaType[]; }'`
コントリビューションガイド
評価
この issue はまだ評価されていません。