Skip to content

Reexported types are emitted in js files #38647

Description

Reexported types are emitted as actual modules in js files generating runtime errors.

Problem occurs in both commonjs and esmodule.

TypeScript Version: 3.8.3

Search Terms:
Reexported types interfaces dts

Code

// types.d.ts
export type Foo = 1;
export type Bar = 2;
//--------------------------------------
// index.ts
export * from "./types"

export default 1;

tsconfig

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs", // or esmodules
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

Expected behavior:
Don't emit types reexports

Actual behavior:

commonjs

"use strict";
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./types"), exports); // runtime error
exports.default = 1;

esnext

export * from "./types";
export default 1;

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions