0

Why when trying to declare a const I get error:

Expecting new line or semicolon

export class MyClass{

    const ALLOC_INVESTORS = "Allocation Investors";

}
3
  • If you try it on the Playground it will tell you that const cannot be used in a class declaration. Commented Sep 14, 2016 at 19:07
  • @MikeMcCaughan what would be the alternative for const inside a typescript class? Commented Sep 14, 2016 at 19:16
  • 1
    stackoverflow.com/q/37265275/215552 :) Commented Sep 14, 2016 at 19:20

1 Answer 1

1

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

readonly ALLOC_INVESTORS:string = "Allocation Investors";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.