Skip to content

no-restricted-property-access: handle used-before-assigned of class properties in initializer and constructor #741

Description

@ajafff
class C {
    prop: string;
    other = this['prop']; // this should be a finding

    constructor(){
        console.log(this.prop); // this is an error
        console.log(this['prop']); // this should be a finding
        this.prop = '';
    }
}

The one in the property initializer should be pretty easy.

Note that checking the use in the constructor needs a complete control flow graph to check for assignments in all possible control flow graphs like o?.[this.prop = ''].prop ?? (this.prop = '');

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions