Answer the question
In order to leave comments, you need to log in
How does it work and what is the name of such a construction in TS?
constructor(private readonly field1, private readonly field2) {}
Answer the question
In order to leave comments, you need to log in
https://www.typescriptlang.org/docs/handbook/2/cla...
compiles to:
constructor(field1, field2) {
this.field1 = field1;
this.field2 = field2;
}
the fields will be inserted immediately after super()
if present or at the beginning of the constructor if super()
not
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question