TS2369

error TS2369: A parameter property is only allowed in a constructor implementation.

Broken Code ❌

1
2
3
class MyMessenger {
constructor(public message: string);
}

Fixed Code ✔️

The constructor implementation is missing curly brackets which is why TypeScript does not recognize the constructor implementation and files error TS2369. To solve it you have to add the missing curly brackets:

1
2
3
class MyMessenger {
constructor(public message: string) {}
}