Why doesn't instanceof work on instances of Error subclasses under babel-node?

前端 未结 2 760
抹茶落季
抹茶落季 2020-11-27 12:33

I am seeing that the instanceof operator doesn\'t work on instances of Error subclasses, when running under babel-node version 6.1.18/Node version

2条回答
  •  孤独总比滥情好
    2020-11-27 12:58

    instanceof will not work for subclassed errors if the compile target is set to "es5". I set the target to "es6" in my tsconfig.json and instanceof produced the right result.

提交回复
热议问题