Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extraneous quotation marks with declare module "name" #2778

Closed
blutorange opened this issue Nov 24, 2024 · 2 comments
Closed

Extraneous quotation marks with declare module "name" #2778

blutorange opened this issue Nov 24, 2024 · 2 comments
Labels
bug Functionality does not match expectation
Milestone

Comments

@blutorange
Copy link

blutorange commented Nov 24, 2024

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
@blutorange blutorange added the bug Functionality does not match expectation label Nov 24, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 24, 2024

TypeDoc probably should be creating modules here... How I despise module augmentations...

I should note that TypeDoc does not have the concept of a folder in its model structure. The illusion of folders in the navigation output was added to make the output nicer for people who insist on creating documentation for applications.

Gerrit0 added a commit that referenced this issue Nov 24, 2024
@blutorange
Copy link
Author

blutorange commented Nov 24, 2024

edit: Just saw you already fixed it, that was quick 👍

How I despise module augmentations...

I sometimes feel this way about the web ecosystem in general... TypeScript is also more flexible than say, Java, which I think makes generating good documentation much harder. In Java you just generate the docs without any customization and you're done.

I should note that TypeDoc does not have the concept of a folder in its model structure. The illusion of folders in the navigation output was added to make the output nicer for people who insist on creating documentation for applications.

Thanks for the info, that was a bit confusing to me at first. Especially since I didn't understand the need for folders -- but since there are none, that's fine : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants