I am analyzing some TypeScript code and I came across this kind of declaration inside a class definition:
constructor(readonly constructorParam : Type) {
// here we don't assign constructorParam to anything
}
But further, I see that constructorParam is used as normal.
Is it possible that it constructorParam property is "created and assigned be default"?
It also is wrapped in export abstract class ... extends ... implements ... (while extends and implement are understandable inheritance keywords, export is used for working with modules, but might be relevant to discussion).
UPDATE
According to this post, it really seems to work like that - creating property and assigning value by default for constructor parameters marked as readonly.
readonly. It saves time assigning each parameter in the constructor. E.g. the following is also possible:constructor(public randomVal: number) {}randomVal?RandomClass, using it like:new RandomClass(5).randomValwould return passed in number 5.