Skip to content

Emitted__exportStar helper has missing ; which causes runtime error #38501

Description

TypeScript Version: 3.9.1-rc

Search Terms:
__exportStar
export star

Code
Input

export *  from './test';

Output

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
} /* There is a missing semi-colon here */
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "./test"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    __exportStar(require("./test"), exports);
});

When module target is configured UMD and helpers are emitted. The __exportStar unnamed function declaration has a missing ;, which causes an error during runtime Uncaught TypeError: (intermediate value)(…) is not a function

Expected behavior:
A semi-colon is added after the unnamed __exportStar function declaration.
Actual behavior:
A semi-colon is missing from the output which cause a runtime error.

Playground Link: https://www.typescriptlang.org/play/?module=3&ts=4.0.0-dev.20200511&ssl=2&ssc=18&pln=2&pc=1#code/KYDwDg9gTgLgBAKjgMyhAtnA5AOgPQzADOMWA3AFBA

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions