Skip to content

Accessing private properties from an external function with this parameter #18281

Closed
@roddolf

Description

@roddolf

If I have a class with a private property:

class MyClass {
  private privateProperty;
}

I would expect that having a function with the this parameter as the class I could access to the private property of the class:

function myFunction( this:MyClass ) {
  this.privateProperty; // Gives an error
}

Since I'm specifying where the function is running, shouldn't it be treated as if it's "inside" the class?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions