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

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

Open
pylixonly opened this issue Jul 24, 2024 · 1 comment
Labels

Comments

@pylixonly
Copy link

pylixonly commented Jul 24, 2024

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

@pylixonly pylixonly changed the title Top-level function comments/JSDocs are stripped when not exported directly Top-level exports comments/JSDocs are stripped when not exported directly Jul 24, 2024
@timocov
Copy link
Owner

timocov commented Aug 20, 2024

Hm, at the glance it seems there should be a more complex check in here to make sure that transitive exports (or re-exports, not sure what exactly cases the issue) are also accounted.

@timocov timocov added the Bug label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants