Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

esModuleInterop is not supported #1112

@rubenlg

Description

@rubenlg

When I run tsickle with esModuleInterop, tsickle produces the wrong javascript, with a regular require instead of goog.require.

Repro steps:

npm install typescript@~3.5.3 tsickle@0.37.0

I wish I could use tsickle 0.37.1, but unfortunally the npm package doesn't have a binary (or a main.js file).

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
  }
}

a.ts:

import * as b from './b';

b.foo();

b.ts:

export function foo() {}

Generated a.js:

goog.module('a');
var module = module || { id: 'a.ts' };
const tsickle_b_1 = goog.requireType("b");
const b = __importStar(require("./b"));
b.foo();

If I don't use import * as ... then the emitted JS is correct.

esModuleInterop is now one of the default flags generated when running tsc --init.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions