ajv-validator / ajv-validator/ajv

JSONSchemaType requires "required" and "additionalProperties", unless it is oneOf schema

オープン
#1,521 コメント 34 件 リアクション 5 件 担当者 0 名 GitHub で見る
docs typescript usage
主要言語
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。