Skip to content

Extraneous quotation marks with declare module "name" #2778

Closed
@blutorange

Description

Search terms

declare module namespace name quote quotation marks

Expected Behavior

When declaring modules via declare module "foo/bar1", I'd expect the module to be named bar1, in the sub folder foo.

Actual Behavior

TypeDoc creates a folder "foo and names the module bar1".

Steps to reproduce the bug

Let's say you have the following file with a few declared modules:

declare module "common" {
    export class Base {}
}
declare module "foo/bar1" {
    import { Base } from "common";
    export class Bar1 extends Base {}
}
declare module "foo/bar2" {
    import { Base } from "common";
    export class Bar2 extends Base {}
}

Running

npx typedoc --entryPoints dist/demo.d.ts --out docs-demo

Creates a doc page like this that includes the quotation marks (which looks somewhat alright as the page title, but strange in the left sidebar)

image

Related

I also noticed --plugin typedoc-plugin-merge-modules seems to fail to merge modules declared in that way. After a quick look, the reason seems to be that TypeDoc creates a project with one child for each module, but the Reflection.kind is Namespace, not Module, and the plugin only picks up modules.

I've read #1301 (comment), which says that module Foo { } is the same as namespace Foo { }. But declare module Foo {} does not seem to be the same as declare module "Foo" {} (note the quotation marks). The former produces a warning that the syntax is outdated and one should use namespace instead, the latter does not produce such a warning.

So I wonder if declare module "Foo" {} should really be considered a namespace, not a module?

image

Environment

  • Typedoc version: 0.27.0-beta.1
  • TypeScript version: 5.6.3
  • Node.js version: v20.18.0
  • OS: Linux 6.8.0-35-generic #35-Ubuntu x86_64 x86_64 x86_64 GNU/Linux

Metadata

Assignees

No one assigned

    Labels

    bugFunctionality does not match expectation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions