You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript should check the access modifier of class properties with "weird" names that look like computed properties but are given literally (e.g. property names with dashes).
Actually, TypeScript even acts a little inconsistent: It fails if trying to access a class property that does not exist, but passes accessing private properties from outside.
Actual behavior:
TypeScript fails for undefined properties, but not for existing private properties.
From #26328: const n = a[nameN]; with nameN being a variable (well in real-life). This issue is specifically about object["literal"]. And ... about undefined vs. private properties behaving differently.
This is longstanding behavior to allow (ugh) the access of these properties. It'd be a very substantial breaking change at this point and we don't intend to invoke that pain.
TypeScript Version: 3.7.2
Search Terms: private computed property
Expected behavior:
TypeScript should check the access modifier of class properties with "weird" names that look like computed properties but are given literally (e.g. property names with dashes).
I understand that there is an intended bypass for "real" computed properties where the index is a non-constant expression (https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#413-property-access). But properties explicitly defined in the class should be checked when accessed literally (see playground example).
Actually, TypeScript even acts a little inconsistent: It fails if trying to access a class property that does not exist, but passes accessing private properties from outside.
Actual behavior:
TypeScript fails for undefined properties, but not for existing private properties.
Related Issues: #26328
Code
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: