ʞᴉɯ
ʞᴉɯ

Reputation: 5594

Visual Studio 2015 typescript "public readonly name: type" marked as error

In Visual Studio 2015, if i write a .ts file with:

class MyClass {
    public pageSize: number;
}

no errors are marked (underlined). If i write instead

class MyClass1 {
    public readonly pageSize: number;
}

i get weird underlines, but the code compiles. Any clue?

Thanks

enter image description here

Upvotes: 1

Views: 420

Answers (1)

Nitzan Tomer
Nitzan Tomer

Reputation: 164397

The readonly properties was only introduced in typescript 2, so if you want to use it then you have to compile using typescript 2.

Your code is compiled in the playground without errors as it uses typescript 2.

Here's how to use it with visual studio.

Upvotes: 1

Related Questions