0

Why when trying to declare a const I get error:

Expecting new line or semicolon

export class MyClass{

    const ALLOC_INVESTORS = "Allocation Investors";

}
CommonSenseCode
  • 23,522
  • 33
  • 131
  • 186
  • If you [try it on the Playground](http://www.typescriptlang.org/play/index.html#src=export%20class%20MyClass%7B%0A%0A%20%20%20%20const%20ALLOC_INVESTORS%20%3D%20%22Allocation%20Investors%22%3B%0A%0A%7D) it will tell you that `const` cannot be used in a class declaration. – Heretic Monkey Sep 14 '16 at 19:07
  • @MikeMcCaughan what would be the alternative for const inside a typescript class? – CommonSenseCode Sep 14 '16 at 19:16
  • 1
    http://stackoverflow.com/q/37265275/215552 :) – Heretic Monkey Sep 14 '16 at 19:20

1 Answers1

1

in case anyone needs. instead of const, use readonly.

readonly ALLOC_INVESTORS:string = "Allocation Investors";
Chris
  • 1,829
  • 1
  • 15
  • 22