https://wanago.io/2019/12/02/javascript-design-patterns-factories-typescript/
In the code above, we specify explicitly that when we create a music teacher, we need to pass the properties of a music teacher. Otherwise, the TypeScript compiler would throw an error.
Thanks to proper typing, TypeScript now knows that the codingTeacher, for example, is an instance of the CodingTeacher class.
Comments
Post a Comment