ajv-validator / ajv-validator/ajv

Using `SomeJTDSchemaType ` as a class property type fails TS compilation

オープン
#2,200 コメント 1 件 リアクション 1 件 担当者 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.12.0`, which is the latest version at the moment.

It might also be worth noting that I've tried the latest TypeScript compiler (`4.9.4`) and the previous minor version (`4.8.4`)

**Your typescript code**

```typescript
import Ajv from 'ajv'
import {AsyncSchema, AsyncValidateFunction} from 'ajv/dist/types'
import {JTDDataType, SomeJTDSchemaType} from 'ajv/dist/types/jtd-schema'

const ajv = new Ajv()

export abstract class MyExampleClass {
protected abstract schema: SomeJTDSchemaType
private _validate?: Promise>>

private get validate(): Promise>> {
this._validate ??= ajv.compileAsync>({...this.schema, $async: true} as AsyncSchema)

return this._validate
}
}
```

**Typescript compiler error messages**

```
error TS2589: Type instantiation is excessively deep and possibly infinite.
```

**Describe the change that should be made to address the issue?**
I am unsure. I've spent the better half of today trying to figure out what the issue is here and have not made much progress.

**Are you going to resolve the issue?**
I have not been able to.

________________

Hi all 👋

I'm new to ajv so it's possible this is user error. I'm trying to add a generic JTD schema property to an abstract class, and I'm attempting to use the `SomeJTDSchemaType` and `AsyncValidateFunction` types to do so. This borks the TypeScript compiler, I'm assuming due to the recursive nature of `SomeJTDSchemaType`. Any ideas?

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

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

評価

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

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

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