Skip to content

feat: prepare direct TypeScript 7 AST migration (stacked on #355 branch) - #1

Open
el-j wants to merge 1 commit into
feat/typescript-7-upgradefrom
feat/typescript-7-direct-ast
Open

el-j wants to merge 1 commit into
feat/typescript-7-upgradefrom
feat/typescript-7-direct-ast

Conversation

@el-j

@el-j el-j commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Stacked PR – base is feat/typescript-7-upgrade (fabien0102#355 in fabien0102/openapi-codegen), not main. Merge fabien0102#355 first.

What this delivers

Everything for the TypeScript 7 migration that does not depend on the native printer, so the remaining work is small once upstream lands.

  • Direct TS 7 AST usage (typescript/ast, typescript/ast/factory) for the stable parts: import factories (phaseModifier), import-usage analysis, getOperationTypes, getRequestBodyType, getDataResponseType, schemaToEnumDeclaration, native scanner in isValidIdentifier.
  • Compat adapter kept only where needed: printer / JSDoc-dependent modules keep importing plugins/typescript/src/typescript.ts. Removing it later is a mechanical follow-up.
  • Plugin is a native ESM package ("type": "module"), bundled with tsup exactly like the CLI. Source imports stay extensionless (no .js suffixes); the plugin tsconfig now inherits the root Bundler resolution. TS 7 only exposes ESM subpaths, so the old Node16/CJS emit could not build.
  • CJS interop wrappers for case, lodash, pluralize (named imports from these CJS packages fail in Node ESM).
  • CLI: getText validates string literals and throws TypeError instead of silently returning ""; updateConfig reuses it.

Not included / blocked on upstream

Dependencies

Validation

  • pnpm check:types ✅
  • pnpm test --run – 28 files / 244 tests ✅
  • pnpm build ✅
  • Built plugins/typescript/lib imported in plain Node ESM and generateSchemaTypes run end-to-end ✅

- Migrate AST consumers/factories to `typescript/ast` and
  `typescript/ast/factory` where the TS 7 API is stable
- Keep printer/JSDoc-dependent modules on the `typescript.ts` adapter
- Make the plugin a native ESM package, bundled with tsup (same as the
  CLI) so source imports stay extensionless
- Add CJS interop wrappers for `case`, `lodash` and `pluralize`
- Harden CLI `getText` with an explicit string-literal check

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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