Skip to content

fix(generator): emit declare namespace instead of declare module - #316

Merged
mfal merged 1 commit into
masterfrom
fix/generator-declare-namespace
Oct 16, 2026
Merged

mfal merged 1 commit into
masterfrom
fix/generator-declare-namespace

Conversation

@mfal

@mfal mfal commented Oct 16, 2026

Copy link
Copy Markdown
Member

Problem

The generator wraps the generated types.ts in export declare module <Name> {. TypeScript 6 and 7 reject this with TS1540 ("A 'namespace' declaration should not be declared using the 'module' keyword"), and ignoreDeprecations: "6.0" does not silence it. Consumers that compile the generated types (e.g. Nexus) are stuck on TypeScript ≤ 5.9.

Changes

  • CodeGenerationModel.compileTypes emits export declare namespace <Name> {. This was the only namespace emitted with module; nested namespaces already used namespace, and no real ambient module declarations are generated.
  • Unit test updated accordingly.
  • v2 and v3-next clients regenerated from the checked-in prod specs — the diff is exactly that one line per file.

Both keywords produce the same declaration, so references like MittwaldAPIV2.Components.Schemas.* are unaffected.

Verification

  • Generator unit tests: 203 passed
  • tsc --noEmit -p packages/mittwald passes with TypeScript 5.7.2 (repo), 5.9.3 and 7.0.2
  • Baseline: with the previous types.ts, TypeScript 7.0.2 fails with TS1540 at src/generated/v2/types.ts(11,23)
  • Regenerating after rebasing onto master leaves the tree clean

🤖 Generated with Claude Code

TypeScript 6 and 7 reject `module` for namespace declarations with
TS1540, and `ignoreDeprecations: "6.0"` does not silence it. This
blocked consumers that compile the generated types.ts from upgrading
TypeScript beyond 5.9. The emitted declaration is semantically
identical, so existing `MittwaldAPIV2.*` references keep working.

Regenerated the v2 and v3-next clients from the checked-in specs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mfal mfal self-assigned this Oct 16, 2026
@mfal
mfal enabled auto-merge (squash) October 16, 2026 07:57
@mfal
mfal merged commit 16d9dd0 into master Oct 16, 2026
1 check passed
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.

2 participants