In the constructor, we want to set the prop to readonly, you need to do like this:
class Superhero { readonly name: string constructor( name: string, editor: string, createdYear: number ) { name = this.name; } }
In the constructor, we want to set the prop to readonly, you need to do like this:
class Superhero { readonly name: string constructor( name: string, editor: string, createdYear: number ) { name = this.name; } }
[TS] Class Properties Public, Private and Read Only Modifiers
原文:https://www.cnblogs.com/Answer1215/p/8419135.html