Skip to content

Top-level exports comments/JSDocs are stripped when not exported directly #328

@amsryq

Description

@amsryq

Bug report
Repository with the entire setup (reproducible): https://github.com/amsyarasyiq/dts-bundle-jsdocs-strip-issue

In below example, function executePlugins and array plugins docs are stripped after getting bundled.
Input code

// plugins.ts
export interface TestPlugin {
    /**
     * The unique name of the plugin
     */
    name: string;
    /**
     * Brief description of the plugin
     */
    description: string;
    /**
     * Function to be executed on plugin execution
     */
    execute(): void;
}

/**
 * Responsible of holding all installed plugins
 */
export const plugins: TestPlugin[] = [];

/**
 * Executes all plugins that are not excluded.
 *
 * @param {string[]} excluded - An array of plugin names to exclude.
 * @return {void} This function does not return a value.
 */
export function executePlugins(excluded: string[] = []): void {
    for (const plugin of plugins) {
        if (!excluded.includes(plugin.name)) {
            plugin.execute();
        }
    }
}
// input.ts
export * as plugins from "./plugins";

Expected output

export interface TestPlugin {
	/**
	 * The unique name of the plugin
	 */
	name: string;
	/**
	 * Brief description of the plugin
	 */
	description: string;
	/**
	 * Function to be executed on plugin execution
	 */
	execute(): void;
}
/**
 * Responsible of holding all installed plugins
 */
declare const plugins: TestPlugin[];
/**
 * Executes all plugins that are not excluded.
 *
 * @param {string[]} excluded - An array of plugin names to exclude.
 * @return {void} This function does not return a value.
 */
declare function executePlugins(excluded?: string[]): void;

declare namespace plugins$1 {
	export { TestPlugin, executePlugins, plugins };
}

export {
	plugins$1 as plugins,
};

export {};

Actual output

export interface TestPlugin {
	/**
	 * The unique name of the plugin
	 */
	name: string;
	/**
	 * Brief description of the plugin
	 */
	description: string;
	/**
	 * Function to be executed on plugin execution
	 */
	execute(): void;
}
declare const plugins: TestPlugin[];
declare function executePlugins(excluded?: string[]): void;

declare namespace plugins$1 {
	export { TestPlugin, executePlugins, plugins };
}

export {
	plugins$1 as plugins,
};

export {};

Additional context
dts-bundle-generator version: 9.5.1
bun dts-bundle-generator -o ./test/output.d.ts ./test/input.ts --no-check

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions