Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Non recursive schema resolves as "any" and fails the build #146

Closed
mrded opened this issue May 25, 2023 · 2 comments
Closed

BUG: Non recursive schema resolves as "any" and fails the build #146

mrded opened this issue May 25, 2023 · 2 comments

Comments

@mrded
Copy link

mrded commented May 25, 2023

  • json-schema-to-ts: 2.9.0
  • node: 18.13.0
  • typescript: 4.2.3

I'm trying to turn into types a very basic schema:

const responseSchema = {
  type: 'object',
  additionalProperties: false,
  properties: {
    success: { type: 'boolean' },
    statusCode: { type: 'number' },
    message: { type: 'string' }
  },
  required: ['success', 'statusCode', 'message']
} as const;

type Response = FromSchema<typeof responseSchema>;

Which resolves as any.

When I try to build it, it fails with TS2589: Type instantiation is excessively deep and possibly infinite. error.

image

@mrded
Copy link
Author

mrded commented May 25, 2023

FYI: rolling back to v2.8 fixes the issue.

@ThomasAribart
Copy link
Owner

@mrded Yes it's a known issue, will be working on this tomorrow. Closing this as it's a duplicate of #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants