TypeScript is not recognized when you invoke a method that you assign inside the Constructor of TypeScript is not recognized.

Asked 2 years ago, Updated 2 years ago, 76 views

class Block{
    // // Implements about block. internal.
    blockProperties: Object;

    constructor(){
        this.applyBlockPrototype();
    }

    applyBlockPrototype(): void{
        this.blockProperties = new Object();
    }
}

If you have this code, you can't compile blockProperties because it's not initialized, and the IDE also comes straight out as a red line.

But it's the same logic, and there's no error.

class Block{
    // // Implements about block. internal.
    blockProperties: Object;

    constructor(){
        this.blockProperties = new Object();
    }
}

What on earth did I do wrong?

typescript constructor

2022-09-20 21:29

1 Answers


2022-09-20 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.