ajv-validator / ajv-validator/ajv

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

未關閉
#1,521 34 則留言 5 個 reaction 已指派 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 摘要。