Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

tsgo incorrectly emits both ESM and CJS exports when compiling .js files containing exports.xxx statements #2527

Closed

Description

Steps to reproduce

Minimal reproducing example: https://github.com/psm14/tsgo-exports-bug-reproduction

Source sample

/**
 * Greets a user by name.
 * @param {string} name - The name to greet
 * @returns {string} The greeting message
 */
exports.greet = function greet(name) {
  return `${DEFAULT_PREFIX}, ${name}!`;
};

Behavior with [email protected]

"use strict";
/**
 * Greets a user by name.
 * @param {string} name - The name to greet
 * @returns {string} The greeting message
 */
exports.greet = function greet(name) {
    return `${DEFAULT_PREFIX}, ${name}!`;
};

Behavior with tsgo

"use strict";
/**
 * Greets a user by name.
 * @param {string} name - The name to greet
 * @returns {string} The greeting message
 */
export var greet = function greet(name: string): string {
    return `${DEFAULT_PREFIX}, ${name}!`;
};
/**
 * Greets a user by name.
 * @param {string} name - The name to greet
 * @returns {string} The greeting message
 */
exports.greet = function greet(name) {
    return `${DEFAULT_PREFIX}, ${name}!`;
};

Activity

  1. changed the title [-]tsgo incorrectly emits both ESM and CJS exports when compiling `.js` files containing `exports.xxx` statuements[/-] [+]tsgo incorrectly emits both ESM and CJS exports when compiling `.js` files containing `exports.xxx` statements[/+] on Jan 16, 2026
  2. jakebailey commented on Jan 16, 2026

    @jakebailey
    Member

    I suspect this is fixed by one of the fixes in #2513

  3. ahejlsberg commented on Jan 16, 2026

    @ahejlsberg
    Member

    I suspect this is fixed by one of the fixes in #2513

    It is indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions