Working with Strict Property Initialization
class Account {
userName!: string;
state: State = "active";
orders?: number[];
constructor(public id: number) {
fetch(`/api/getName?id=${id}`)
.then((res) => res.json())
.then((data: User) => (this.userName = data.userName));
}
}