Unexpected “Uncaught TypeError: XXX is not a constructor” errors with Babel and ES6

前端 未结 6 481
無奈伤痛
無奈伤痛 2020-12-29 19:04

I am giving a try to Webpack, and am giving a try to the instructions in this tutorial, give or take a few custom things.

This is simple code, really, but I\'m quite

6条回答
  •  半阙折子戏
    2020-12-29 19:32

    It's not the problem in this particular question, but for some reasons, babel does not hoist classes in the same file.

    So if you declare your class Token at the top of the file, and write later new Token(), it will run.

    If you declare your class after the constructor call, you will have the xxx is not a constructor error

提交回复
热议问题