Skip to content

Avoid double-transformation of a file when multiple ts-node hooks are registered #409

Description

@sixmen

Maintainer edit: If you would like to submit a pull request implementing this feature, I have described a straightforward implementation here: #409 (comment)

If I require 'ts-node/register' twice, it does not run well. For examples,

my.ts:

export default class My {
  msg: string;
  constructor() {
    this.msg = 'hello';
  }
}

index.js:

require('ts-node/register');
My = require('./my').default;
console.log(new My().msg);

If I run with node index.js, it works. But if I run with ts-node index.js, it fails.

In the real world, I run app with ts-node.
And config module, which I use, also register ts-node ( https://github.com/lorenwest/node-config/blob/master/lib/config.js#L872 ).

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions