这是indexloc提供的服务,不要输入任何密码
Skip to content

Error: namespace must have a "ModuleBlock" body. #1343

@softmarshmallow

Description

@softmarshmallow

the dts will fail when namespaces are nested and declared is a different body.

export namespace cmath {}
export namespace cmath.delta {}
export namespace cmath.vector2 {}
...

This works perfectly fine and a valud ts, and works well with other compilers, this fails with dts with

Error: namespace must have a "ModuleBlock" body.

  361 |     function powerset<T>(arr: T[], k?: number): T[][];
  362 | }
> 363 | declare namespace cmath.delta {
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    at DeclarationScope.convertNamespace (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/rollup.js:5749:17)
    at Transformer.convertNamespaceDeclaration (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/rollup.js:5917:15)
    at Transformer.convertStatement (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/rollup.js:5891:23)
    at new Transformer (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/rollup.js:5836:16)
    at convert (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/rollup.js:5827:27)
    at Object.transform (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/rollup.js:6227:29)
    at Object.writeFile (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/rollup.js:6366:55)
    at writeFile (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/typescript.js:20370:8)
    at printSourceFileOrBundle (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/typescript.js:120018:5)
    at emitDeclarationFileOrBundle (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/typescript.js:119911:26)
Error: error occurred in dts build
    at Worker.<anonymous> (/Users/softmarshmallow/Documents/Apps/grida/grida/node_modules/.pnpm/tsup@8.5.0_jiti@2.4.2_postcss@8.5.3_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/dist/index.js:1545:26)
    at Worker.emit (node:events:518:28)
    at MessagePort.<anonymous> (node:internal/worker:268:53)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
DTS Build error
 ELIFECYCLE  Command failed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions