Skip to content

False positive for TS2729 (use before initialization) with target = ESNext #44298

Closed
@slavafomin

Description

@slavafomin

Bug Report

Hello!

I've encountered this problem after updating my project to the latest TypeScript 4.3.2.

The bug looks similar to #37573.

💻 Code

script.ts

class Foo {

  constructor(private value) {
  }

  anotherValue = this.value;

}

tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext"
  }
}

This happens only when using ESNext as a target. Using ES2020 works correctly. Could you also elaborate on the difference of these two settings?

🙁 Actual behavior

I'm getting an error: error TS2729: Property 'value' is used before its initialization.

🙂 Expected behavior

The code should compile just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions