ReviewOS

stacks/dtsx

Emitter drops the space between interface name and extends clause inside declare-module blocks

#3103
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Bug

When a .ts source contains an interface with an extends clause inside a declare module block, the generated .d.ts is missing the space between the interface name and extends, producing output that fails to parse.

Input (src/request-augmentation.ts):

export type StacksRequestExtensions = StacksRequestMarkers & StacksRequestMacros

declare module '@stacksjs/bun-router' {
  interface EnhancedRequest extends StacksRequestExtensions {}
}

Output (dist/request-augmentation.d.ts):

declare module '@stacksjs/bun-router' {
  interface EnhancedRequestextends StacksRequestExtensions  {}
}

tsc then fails with error TS1005: '{' expected — and since TS1005 is a syntax error, skipLibCheck cannot suppress it, so any downstream project consuming the generated types fails to typecheck.

Notes

  • Reproduced on both @stacksjs/dtsx / bun-plugin-dtsx 0.9.23 and 0.10.8 (latest).
  • The exact formatting of the source doesn't matter — single-line body, multi-line body, single parent, and multiple parents (extends A, B) all emit the same mangled output (name and extends fused, double space before the body).
  • Interfaces with extends at the top level of a module emit correctly; the bug only appears for interfaces nested inside declare module '...' { } augmentation blocks.
  • Encountered in a Stacks app: storage/framework/core/router/src/request-augmentation.ts. We're currently working around it with a post-build string repair in the package's build.ts.

🤖 Generated with Claude Code

Sign in to comment on this issue.