Skip to content

importHelpers not respected when exporting defaults #58827

Closed as not planned
Closed as not planned

Description

🔎 Search Terms

"importHelpers"

"default exports"

"tslib"

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Can't create playground as multiple files are required to demonstrate

💻 Code

src/exporter.ts:

export default function foo(): boolean {
    return true
}

src/index.ts:

export { default as foo } from './exporter'

🙁 Actual behavior

With importHelpers set to true and noEmitHelpers set to false I expect src/index.ts to be compiled to something like:

"use strict";
const tslib_1 = require("tslib");
Object.defineProperty(exports, "__esModule", { value: true });
exports.foo = void 0;
var exporter_1 = require("./exporter");
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return tslib_1.__importDefault(exporter_1).default; } });

🙂 Expected behavior

src/index.ts is actually compiled to:

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.foo = void 0;
var exporter_1 = require("./exporter");
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(exporter_1).default; } });

i.e. it appears for an export { default as ... } statement, the importHelpers property is being ignored.

Additional information about the issue

No response

Activity

  1. jakebailey commented on Jun 11, 2024

    @jakebailey
    Member

    This does show in the playground: Playground Link

    But, it's also fixed in 5.5.

  2. jakebailey commented on Jun 11, 2024

    @jakebailey
    Member

    Fix was in #57220, so this is a dupe of #40328.

  3. added
    Duplicate
    on Jun 11, 2024
  4. typescript-bot commented on Jun 14, 2024

    @typescript-bot
    Contributor

    This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  5. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions