Skip to content

esModuleInterop: invalid code emited when export default import #35800

Closed

Description

TypeScript Version: 3.7.3

Search Terms:
esModuleInterop export default

Code (javascript)
index.js

export {
  default as myFunction
} from 'somewhere';

Expected behavior:

var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "somewhere"], function (require, exports, somewhere_1) {
    "use strict";
    exports.__esModule = true;
    exports.myFunction = __importDefault(somewhere_1)["default"];
});

Actual behavior:

define(["require", "exports", "somewhere"], function (require, exports, somewhere_1) {
    "use strict";
    exports.__esModule = true;
    exports.myFunction = somewhere_1["default"];
});

Compiler options:

{ 
  "compilerOptions": {
    "outDir": "./out",
    "allowJs": true,
    "checkJs": false,
    "module": "amd",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": false
  },
  "include": [
    "index.js"
  ]
}

Activity

  1. added
    Needs Investigation
    on Dec 20, 2019
  2. ajafff commented on Dec 30, 2019

    @ajafff
    Contributor

    The same issue exists for other module emits like commonjs.
    export {default} from 'somewhere'; is also missing __importDefault

  3. added
    Rescheduled
    on May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Needs InvestigationRescheduled

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ Proxy