Skip to content

esModuleInterop: invalid code emited when export default import #35800

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

Closed
TheWind3 opened this issue Dec 20, 2019 · 1 comment · Fixed by #39490
Closed

esModuleInterop: invalid code emited when export default import #35800

TheWind3 opened this issue Dec 20, 2019 · 1 comment · Fixed by #39490
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@TheWind3
Copy link

TheWind3 commented Dec 20, 2019

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"
  ]
}
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Dec 20, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.9.0 milestone Dec 20, 2019
@ajafff
Copy link
Contributor

ajafff commented Dec 30, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants