Skip to content

should warn/error on forward references during field initialization #12673

@Spongman

Description

@Spongman

TypeScript Version: 2.0.10

class Test
{
    _b = this._a; // undefined, no error/warning
    _a = 3;

    static _B = Test._A; // undefined, no error/warning
    static _A = 3;
    
    method()
    {
        let a = b; // Block-scoped variable 'b' used before its declaration
        let b = 3;
    }
}

I'd expect the forward field references to trigger an error (or at least a warning, maybe configurable) similar to function locals.

Metadata

Metadata

Assignees

Labels

CommittedThe team has roadmapped this issueFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions