lundi 6 août 2018

When use a interface or class in Typescript

I have a simple scenario of a login that requires user's input a email and password in Typescript. I need to create some type to get this strong-typed and send it to the back-end.

Should this be written as:

export interface UserLogin {
  email: string;
  password: string;
}
//OR
export class UserLogin {
  email: string;
  password: string;
}

And how to know when is the scenario to use any of these?




Aucun commentaire:

Enregistrer un commentaire