Recently installed new TS version into VS2013 and tried to use protected
modifier.
However TS validator shows me an error (and underlines protected
word with a red line.
I get an error like
Use of future reserver word. ; expected
looks like it's looking into old TS definitions.
Checked the project file and there is 1.1 version of TypeScript.
also running tsc -v
produces 1.3.0
.
Does somebody of you guys experience that? What i'm missing and what to do to fix that.
Thank you a lot for any help.
export class SomeClass {
protected metadata: Metadata;
protected subItems: SomeClass[];
constructor() {
}
}
There is some terminology you’ll frequently see in error messages that is helpful to understand. TypeScript considers a type assignable to another type if one is an acceptable substitute for the other.
The protectedkeyword has landed. It is currently pre-release. If you are using a very new version of TypeScript you can now use the protectedkeyword... the answer below is for older versions of TypeScript. Enjoy. View the release notes for the protected keyword
Old Answer TypeScript has only private- not protected and this only means private during compile-time checking. If you want to access super.propertyit has to be public.
protected works in TypeScript very similarly like it does from C#. The TypeScript release notes document it as such: The new protected modifier in classes works like it does in familiar languages like C++, C#, and Java. A protected member of a class is visible only inside subclasses of the class in which it is declared
thank you all guys. for your answers! the reason was (oh, what's the shame =) ) the ReSharper. It's validation was showing that error, suspending it i'm getting no errors now. Looks like JetBrains guys should update their definitions like Web Essentials did. As they aren't compatible with new TS version, 1.3. And no updates pending as for now.
Hope, it'll be useful for somebody else.
The answer to your question then is ReSharper 9.0 EAP. It supports TypeScript 1.3 features: 'protected' modifier and tuples. You're welcome to try it. Though, yes, it's a pre-release version, so overall stability is not strictly guaranteed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With