es6-error: Unable to import using TypeScript on nodejs

In Typescript, this line:

import ExtendableError from 'es6-error'

translates to this line:

var ExtendableError = require('es6-error').default

However, .default is undefined due to the incorrect way these two lines are written. A correct version of those two lines would read like this:

module.exports = ExtendableError;
module.exports.default = ExtendableError;

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 18 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I suggest to change typedefinitions to

export = Error

It would allows to import * as ExtendableError from "es6-error", and import ExtendableError from "es6-error" with --allowSyntheticdefaultImports