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

Add reasonable max for tuple types (fix #438) #451

Merged
merged 1 commit into from
May 22, 2022
Merged

Add reasonable max for tuple types (fix #438) #451

merged 1 commit into from
May 22, 2022

Conversation

bcherny
Copy link
Owner

@bcherny bcherny commented May 22, 2022

This diff adds a reasonably large maximum size for how many members we emit for bounded-size arrays.

Before, we'd emit whatever number was specified by maxItems unless a user opted out of this with the ignoreMinAndMaxItems option.

Now, we default to emitting a union of TypeScript tuples for arrays where maxItems - minItems > N, where N defaults to 20 and can be overridden with the maxItems option. We also emit JSDoc blocks for minItems and maxItems, to more explicitly annotate the intent behind the JSON-Schema.

Alternative approaches considered:

  1. Do nothing. This DevX isn't great, as some users will see a cryptic OOM error and not know how to fix it.
  2. Throw and suggest the user enables ignoreMinAndMaxItems if we detect too large a number of cycles when emitting tuple members. This is more explicit, but just looking at number of cycles isn't a reliable indicator of OOMs.

@bcherny bcherny merged commit a7d14c4 into master May 22, 2022
@bcherny bcherny deleted the 438 branch May 22, 2022 02:56
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

Successfully merging this pull request may close these issues.

1 participant