Skip to content

JS: Can't assign to superclass property #26284

Open
@ghost

Description

TypeScript Version: 3.1.0-dev.20180807

Code

a.js

class A {
    constructor() {
        this.initializer = 2;
    }
}

class B extends A {
    constructor() {
        super();
        this.initializer = this.initializer + 1;
    }
}

Expected behavior:

No error.

Actual behavior:

src/a.js:10:9 - error TS7022: 'initializer' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

10         this.initializer = this.initializer + 1;

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationDomain: JavaScriptThe issue relates to JavaScript specificallycheckJsRelates to checking JavaScript using TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions