Skip to content

feat(generate-blueprint): add TypeScript blueprint generation support#32863

Open
chengyixu wants to merge 1 commit intojhipster:mainfrom
chengyixu:generate-typescript-blueprints
Open

feat(generate-blueprint): add TypeScript blueprint generation support#32863
chengyixu wants to merge 1 commit intojhipster:mainfrom
chengyixu:generate-typescript-blueprints

Conversation

@chengyixu
Copy link
Copy Markdown

Summary

Adds a --ts CLI option to the generate-blueprint generator that produces TypeScript (.ts) blueprints instead of JavaScript (.js/.mjs).

Changes

  • New ts config option (--ts CLI flag) to opt into TypeScript blueprint generation
  • When ts=true, blueprintMjsExtension resolves to 'ts' instead of 'js'/'mjs'
  • Generator files (index.ts, command.ts, generator.ts, generator.spec.ts) use .ts extensions with proper TypeScript type annotations (replacing JSDoc @type comments)
  • .blueprint/ internal files (commands.ts, generator.ts, index.ts, etc.) also output as .ts with TypeScript syntax
  • tsconfig.json template updated with TypeScript-optimized settings when ts is enabled:
    • module: "preserve" for native TS execution
    • noEmit: true
    • rewriteRelativeImportExtensions: true
    • erasableSyntaxOnly: true
    • verbatimModuleSyntax: true
  • package.json additions for TypeScript mode:
    • typescript added as a devDependency
    • tsc added to the pretest script
    • Published files pattern updated to include .ts and exclude .spec.ts
  • typescriptEslint enabled when ts mode is active
  • 100% backward compatible - existing JS/MJS generation is completely unchanged

Design Decisions

  • Follows the same patterns established in @mshima's entity-audit TypeScript branch
  • Reuses the existing blueprintMjsExtension property (extending it to support 'ts' value) rather than creating a parallel system
  • The ts option automatically sets js: false in the configuring phase
  • Template EJS files conditionally output TypeScript syntax vs JSDoc based on blueprintMjsExtension === 'ts'

Closes #32217

Test plan

  • Verify tsc --noEmit passes (confirmed locally)
  • Run generate-blueprint with --ts flag and verify .ts files are generated
  • Run generate-blueprint without --ts and verify existing behavior unchanged
  • Run generate-blueprint --ts --local-blueprint and verify .mjs behavior for local blueprints
  • Verify generated TypeScript blueprint can be installed and used with JHipster

🤖 Generated with Claude Code

Add --ts CLI option to generate TypeScript (.ts) blueprints instead of
JavaScript (.js/.mjs). When enabled:

- Generated blueprint files use .ts extensions
- TypeScript type annotations replace JSDoc @type comments
- tsconfig.json configured with module:preserve, noEmit, and
  rewriteRelativeImportExtensions for native TS execution
- typescript added as devDependency with tsc in pretest
- .blueprint/ internal files also output as .ts
- Published files pattern updated for .ts spec exclusion

Backward compatible - existing JS/MJS generation is unchanged.

Closes jhipster#32217

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.

Generate TypeScript blueprints instead of JavaScript

1 participant