Skip to content

Typescript 4.7.3 bracketed class property compilation error strictPropertyInitialization:trueΒ #49594

Closed
@BzenkoSergey

Description

@BzenkoSergey

Bug Report

πŸ”Ž Search Terms

strictPropertyInitialization bracketed class property

πŸ•— Version & Regression Information

Typescript 4.7.3, 4.7.2

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

enum A {
  A = 'A',
  B = 'B'
}

class B {
  [A.A]: string;

  constructor() {
    this[A.A] = '1';
    this.A = '1';
    this['A'] = '1';
  }
}

πŸ™ Actual behavior

Compilation error:
Error: Property '[A.A]' has no initializer and is not definitely assigned in the constructor.

πŸ™‚ Expected behavior

Seems it should be compiled without errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions