Skip to content

ESNext+[[Define]]: false positive error accessing parameter property of base class in initializer of derived class #36442

Description

TypeScript Version: 3.8.0-dev.20200125

Search Terms:

Code

// @target: esnext
// @useDefineForClassFields. true
class C {
    constructor(public foo: string) {}
}

class D extends C {
    bar = this.foo;
}

Expected behavior:

No error. The constructor of C (and therefore the initialization of foo) is already executed when bar is initialized.

Actual behavior:

used before initialization error on this.foo

Playground Link: https://www.typescriptlang.org/play/?useDefineForClassFields=true&target=99&ts=3.8.0-dev.20200125&ssl=7&ssc=2&pln=1&pc=1#code/MYGwhgzhAEDC0G8BQ1XWAewHYQC4CcBXYXDfACgAdCAjEAS2GgDMMMAuaPferAcwCUiAL5JRSUJBgARaAFMAHrjlYAJjHjI00GmHzQAvNFwALehAB0rDAG4xQA

Related Issues: #36425 Nathan Shively-Sanders (@sandersn)

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions