Skip to content

Checker: direct reads of later class fields omit TS2729 #3581

Closed

Description

@nickna

The checker accepts a direct class field read before the referenced field is initialized.

class C {
    z = this.y;
    y = 1;
}

Pinned TypeScript 6.0.3 with --ignoreConfig --strict --noEmit reports TS2729 at this.y (Property 'y' is used before its initialization). SharpTS exits successfully with --no-tsconfig --strict --noEmit on frozen cabb41636 (CLI SHA-256 5335B14C2A96172D0372D8FCDD75264741EB8A0B19C0273737C3BBF2967D3ACE) and PR #3577 head cc5f1af6b.

A read deferred until after construction, such as z = () => this.y, should remain valid. #3554 concerns recovering the type of a field that depends on a cyclic getter. This source has no getter, cycle, closure, inheritance, or constructor body. Found while comparing #3577's automated review example against TypeScript.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions