Answers for "typescript how to type class methods"

0

typescript class

interface User {
  name: string;
  id: number;
}
 
class UserAccount {
  name: string;
  id: number;
 
  constructor(name: string, id: number) {
    this.name = name;
    this.id = id;
  }
}
 
const user: User = new UserAccount("Murphy", 1);
Try
Posted by: Guest on March-18-2022

Code answers related to "TypeScript"

Browse Popular Code Answers by Language