Skip to content

docs: clarify compiler setup for TypeScript 7 applications - #2862

Open
shreyam1008 wants to merge 1 commit into
openapi-ts:mainfrom
shreyam1008:docs/typescript-7-codegen-setup
Open

docs: clarify compiler setup for TypeScript 7 applications#2862
shreyam1008 wants to merge 1 commit into
openapi-ts:mainfrom
shreyam1008:docs/typescript-7-codegen-setup

Conversation

@shreyam1008

Copy link
Copy Markdown

Changes

Correct the setup commands in the quickstart and Node API guide to install typescript@5, matching the currently published openapi-typescript@7.13.0 peer range. Installing an unqualified typescript now selects TypeScript 7, whose root module does not provide the classic compiler API used by the generator.

For TS7 applications, explain how to keep the native application compiler unchanged and run generation in a separate tooling package. Custom transforms and returned AST nodes must share the generator's JS compiler; the generated source is the boundary between that tool and the TS7 application.

Related to #2841. This is a documented workaround, not native TS7 API support, and does not close the underlying compatibility issue. It does not duplicate #2818's proposed TS6 peer-range change or change compiler ownership/runtime dependencies.

How to Review

Only docs/introduction.md and docs/node.md change. No package, lockfile, runtime, generated output, or AST contract changes.

Verified locally with Node 22.12.0 and Bun 1.4.0 using two independent package directories:

  • Application: typescript@7.0.2.
  • Tooling: published openapi-typescript@7.13.0 and typescript@5.9.3.
  • Generate from a small local OpenAPI 3.0.3 schema with a required string name and optional date-time createdAt.
  • Compile a consumer of the generated components type using the application's TS7 compiler, --noEmit --strict --skipLibCheck false; a valid assignment passes and an intentional numeric-name assignment is rejected via @ts-expect-error.
  • Both ESM and CJS programmatic generation pass. An ESM transform returns ts.factory.createTypeReferenceNode("Date"); printing yields createdAt?: Date. Returned nodes can be inspected with ts.isInterfaceDeclaration.
  • Assert generator and callback script resolve exactly the same typescript module, version 5.9.3.
  • git diff --check passes.

The complete documentation site build and repository-wide suites were not run for this small Markdown correction. No claim of testing native TS7 AST interoperability is made.

Microsoft's explanation: https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0 . The examples here retain TS5 because it is the currently declared supported peer, whereas TS6 widening remains proposed separately.

Checklist

  • Unit tests updated — not applicable: documentation-only correction; the setup and compiler boundary were smoke-tested as described above.
  • docs/ updated (if necessary)
  • pnpm run update:examples run — not applicable: no generator output change.

Separate note: AI assistance

Prepared with Codex/Astra assistance. The recommendation was independently checked against the public AST API and the documented setup was executed locally before submission. A private-compiler runtime patch was deliberately not included because it could break existing custom transforms using a different compiler's AST.

@shreyam1008
shreyam1008 requested a review from a team as a code owner September 6, 2026 12:16
@netlify

netlify Bot commented Sep 6, 2026

Copy link
Copy Markdown

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ae62b5c

@changeset-bot

changeset-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ae62b5c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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