TypeScript: Unnamed default exports don't work with `--t es6 --m commonjs`

Compiling the following code:

"use strict";
export default class {};

Using the command line tsc --t es6 --m commonjs produces illegal JavaScript:

"use strict";
class {
}
exports.default = default_1
;

I realize this is a weird combination of switches, however it seems necessary to target current versions of Node.js/V8 that don’t yet natively support ES6 modules.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 29 (17 by maintainers)

Commits related to this issue

Most upvoted comments

General questions should be on StackOverflow, Gitter or IRC, but the following works:

declare namespace TrailsController {
  class TrailsController {
    app: {
      config: any;
      sitemap: any;
      routes: { path: string, config: {app?: any} }[];
      services: any;
    };
    log: any;
    id: any;
    __: any;
    config: any;

    constructor(app: any);
  }
}

declare module "trails-controller" {
  const TrailsController: TrailsController.TrailsController;
  export = TrailsController;
}