Skip to content

JSDocs comments being removed while autogenerating a .d.ts file for a const JavaScript namespace #46010

@PSYmoom

Description

@PSYmoom

Bug Report

I am currently trying to autogenerate .d.ts files for my JavaScript API using --declaration and I am running into problems. All of the files which use a const namespace will have all of their comments removed, including the JSDocs ones. I have set removeComments as false in tsconfig and sanity checked it by a class with comments and all of the comments were retained in the class, but not the namespace.

🔎 Search Terms

Duplicate methods --declaration
namespace .d.ts bug

🕗 Version & Regression Information

4.4.3 but happens with any 4.x.x version I've tried (haven't tried earlier versions).

⏯ Playground Link

The Playground was not playing nicely with emitDeclaration and filenames with .js extension

💻 Code

/**
 * Foo namespace
 * @namespace
 */
const Foo = {
    /** Test function */
    foo: function() {},
    /** Test property */
    bar: 1
}

🙁 Actual behavior

declare namespace Foo {
    function foo(): void;
    const bar: number;
}

🙂 Expected behavior

 /**
  * Foo namespace
  * @namespace
  */
 declare namespace Foo {
    /** Test function */
    function foo(): void;
    /** Test property */
    const bar: number;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Comment EmitThe issue relates to the emission of comments when compiling

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions