Skip to content

Dynamic import not correctly in export assignments #18968

Closed
@mhegazy

Description

@mhegazy

From #17060 (comment)

This is still an issue when the dynamic import is used when exporting a default object:

export default {
    getInstance: function () {
        return import('./foo2');
    }
}

transpiles to

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
    getInstance: function () {
        return import('./foo2');
    }
};

whereas naming the export it works:

export let defaultExport = {
    getInstance: function () {
        return import('./foo2');
    }
}

// transpiles to

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultExport = {
    getInstance: function () {
        return Promise.resolve().then(function () { return require('.foo2'); });
    }
};

typescript version: 2.5.3

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueHigh Priority

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions