ardatan / feTS

🗹 TypeScript HTTP Framework focusing on e2e type-safety, easy setup, performance & great developer experience
https://the-guild.dev/openapi/fets
MIT License
630 stars 29 forks source link

Recursive schema with integer type and format: int64 returns incorrect type #1916

Open akifunal opened 1 month ago

akifunal commented 1 month ago

I've encountered an issue with recursive schemas, where an integer field with format: int64 returns the wrong type when a schema recursively references itself. Specifically, when a schema contains a recursive reference to itself (e.g., through a parent property), the integer field returns number instead of the expected number | bigint .

This issue does not occur when the recursive reference points to a different schema. In those cases, the integer field correctly returns number | bigint.

To Reproduce Steps to reproduce the behavior:

typescriptlang playground

Expected behavior

For an integer field with format: int64, the inferred TypeScript type should be number | bigint | undefined, even when the schema recursively references itself.

Actual behavior

When a schema recursively references itself, the integer field returns only number, omitting bigint.

Environment:

OS: MacOS sequoia 15.0 package-name...: fets@0.8.3 NodeJS: 20.14.0 TypeScript: 5.5.4