This release collects the fixes and small features merged since 15.0.4. Several of them correct types that were previously emitted wrong, so existing schemas may generate different output; hence the major version.
New:
e3c7776 Feat: Support OpenAPI 3.0 nullable: true, including next to a $ref; such schemas now emit T | null (#755, fixes #410)
ab31f41 Feat: Support draft-3 / Swagger 2 property-level required: true; such properties are now emitted as required (#756, fixes #440, #6)
111c187 Feat: Resolve draft-07 named-anchor $refs ("#name" matching a sibling $id: "#name") instead of crashing (#744, fixes #220)
May change emitted types for existing schemas:
efceb64 Bugfix: Multiple patternProperties (or patternProperties with additionalProperties: false) are folded into one index signature typed as the union of their value types, instead of being dropped (#754, fixes #160, #315)
b84b3da Bugfix: allOf members made up only of unsupported keywords (eg. if/then, not) no longer add a stray {[k: string]: unknown} to the intersection (#743, fixes #369)
d8618e5 Bugfix: properties/patternProperties on a nested schema were dropped when combined with oneOf/anyOf/allOf; they are now intersected with the compound type (#708, fixes #630)
4eee0f1 Bugfix: $refs to definitions with dotted names (eg. #/definitions/v1.ManagedFieldsEntry) were truncated at the first dot (V1); the full name is now used (V1ManagedFieldsEntry) (#705, fixes #645)
7a3dd8e Bugfix: Nested arrays with minItems/maxItems are capped by the cumulative product of their bounds against maxItems, falling back to an unbounded array instead of hanging or emitting enormous tuple unions (#703, fixes #690)
34a692c Bugfix: type: null (the JSON null value) is treated as type: "null" instead of as an untyped object (#702, fixes #667)
0f9d309 Bugfix: unreachableDefinitions now declares definitions even when declareExternallyReferenced is off (#706, fixes #652)
1900e1f Bugfix: With inferStringEnumKeysFromValues, a const is emitted as a literal type again rather than a single-member enum (#701, fixes #666)
606e359 Bugfix: A schema with an array type and properties (eg. type: ['object', 'null']) at the root or as an untitled definition compiled to A & (A | null), making the non-object members unreachable; it now emits A | null (#753, supersedes #672)
c73ea75 Bugfix: An empty schema inside allOf (eg. allOf: [{$ref: '#/definitions/User'}, {}]) collapsed the whole intersection to unknown; the empty member is now dropped and User is kept (#752, fixes #654)
9c50776 Bugfix: The description of an inline items schema is no longer dropped; it is added to the JSDoc of the array's declaration as an Items: ... paragraph (#751, fixes #660)
Fixes for crashes and output that did not compile:
b25c768 Bugfix: A root-level $ref to a definition that is itself only a $ref no longer crashes with "Refs should have been resolved by the resolver!" (#741, fixes #740)
b25c768 Bugfix: A root-level $ref to a definition that refers back to itself (directly or through items/properties) compiles instead of crashing with the same error (#741, fixes #132, #730). The referenced definition is still emitted as its own interface alongside the root type
107dd42 Bugfix: Index signatures from patternProperties/additionalProperties are widened to cover sibling named properties, so the interface typechecks (TS2411). Index signatures that already typechecked are emitted type-equivalent to before (#704, fixes #671)
a2234d3 Bugfix: inferStringEnumKeysFromValues no longer produces invalid enum members for non-string, empty or digit-leading values (#694, fixes #657)
377c6a1 Bugfix: A named enum (tsEnumNames) in a position with no name no longer emits a nameless enum declaration; it degrades to a union of literals (#693, fixes #691)
c44faed Bugfix: Generated type names can no longer start with a digit or collapse to an empty name (#698, fixes #640)
8d8a141 Bugfix: Recursive schemas that reach the generator without a name (a self-referencing $ref with a sibling keyword such as description, a recursive oneOf under components/schemas, an untitled recursive schema in another file) are given a generated type name instead of overflowing the stack. Schemas that compiled before are unchanged, except that an anonymous recursive union with a {}/true member now keeps its alias (same type, one extra export type) (#760, fixes #482, #614)
Other:
bf06bbb Bugfix (CLI): Piping a schema on stdin no longer prints a DEP0187 deprecation warning on Node 24 (#750)
3abde40 Perf: compile() no longer scans every definition once per parsed node; schemas with thousands of definitions compile much faster (schemastore's CloudFormation schema: ~54 s -> ~3 s). Generated output is unchanged (#759)
b88891c Perf: Formatting large, mostly quote-free outputs is several times faster (prettier is told the output is a .d.ts, so it skips its JSX-detection scan); a caller's own style.filepath still wins. Generated output is unchanged (#758)
16c2e77 Bugfix (CLI): relative $refs are resolved against each schema file's own directory rather than process.cwd(), so a schema passed by path from another directory finds its siblings; an explicit --cwd still wins (#742, fixes #324, #680)
9219636 Updated runtime dependencies: js-yaml 4 -> 5 (YAML files parse as before, #689), prettier ^3.9 (short unions that fit on one line are no longer wrapped; users on the existing ^3.2.5 range may already see this), @apidevtools/json-schema-ref-parser ^11.9 (#686)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
Release Notes
bcherny/json-schema-to-typescript (json-schema-to-typescript)v16.0.0
Compare Source
This release collects the fixes and small features merged since 15.0.4. Several of them correct types that were previously emitted wrong, so existing schemas may generate different output; hence the major version.
New:
May change emitted types for existing schemas:
Fixes for crashes and output that did not compile:
Other:
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.