Skip to content

Parser rejects definite assignment assertions on private instance fields #3645

Open

Description

@nickna
class C {
    #value!: number;
    read() { return this.#value; }
}

TypeScript 6.0.3 accepts this with --ignoreConfig --strict --target ES2022 --noEmit. SharpTS reports Expect ';' after private field declaration. with --no-tsconfig --strict --noEmit before type checking.

The private-field parser does not consume a definite assignment assertion. This prevents the valid instance-field form; the static private form should instead reach the checker's TS1255 grammar diagnostic.

Found while adding static definite assignment assertion regressions for #3635.

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