Why Does This Typescript Output “[Class] is not a constructor.”?

后端 未结 12 1383
清歌不尽
清歌不尽 2021-01-17 07:55

I\'m working in typescript 1.5 in visual studio. I have a main class called app.ts, and another called FizzBuzzManager.ts. I can\'t figure out what is wrong with this code,

12条回答
  •  长情又很酷
    2021-01-17 08:28

    It might be helpful to think about it as if you were writing the code in JavaScript directly. I came across this question because I got the same error in an Angular 2 test spec written in TypeScript. After thinking about it based on the answers above, I realized that JavaScript would have no idea what my equivalent to your BuzzFeed class was because it was at the bottom of the file.

    I moved the class up to the top of the file before my first describe statement and everything works. Thought this might help others like myself.

提交回复
热议问题