Angular: 7.2.1 ES6 class ReferenceError : Cannot access 'X' before initialization

后端 未结 5 2122
别那么骄傲
别那么骄傲 2020-12-10 10:44

I\'m having the following TypeScript class

export class Vehicule extends TrackableEntity {
  vehiculeId: number;
  constructor() {
    super();
    return s         


        
5条回答
  •  我在风中等你
    2020-12-10 11:20

    Note that this error can also be caused by defining two public @Injectable classes within the same .ts file.

    I've tripped over this more than once when I'm just prototyping stuff locally (especially when refactoring one service into multiple).

    Setting emitDecoratorMetadata: false does fix this situation as well; but in case you're in a hurry to fix something or don't want fiddle with thetsconfig.json file on a large project - it's useful to know that you might be able to fix it by just copying one of the classes into a new file.

提交回复
热议问题