ajv-validator / ajv-validator/ajv

What needs to happen before we can get simultaneous TS inference and validation for JTD schemas?

オープン
#1,902 コメント 0 件 リアクション 4 件 担当者 0 名 GitHub で見る
typescript
主要言語
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

The last I've seen of work on the `JTDSchemaType` and `JTDDataType` is in https://github.com/ajv-validator/ajv/issues/1489
But the docs still say

> type inference is not supported for JTDDataType yet
-[utility-type-for-jtd-data-type](https://ajv.js.org/guide/typescript.html#utility-type-for-jtd-data-type)

**For example, something like**

```typescript
function helper(schema: T) {return schema};
const mySchema = helper({
properties: {
num: {type: "float64"},
nullableEnum: {enum: ["v1.0", "v1.2"], nullable: true},
values: {values: {type: "int32"}},
},
optionalProperties: {
optionalStr: {type: "string"},
},
invalidKey: something // <-- invalid provides an inferred type error in your IDE
})
// And still be able to get inferred data type when the schema is type validated
const data = ajv.compile(mySchema)
let num = data.num // inferred to be number
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

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

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