DEV Community

Discussion on: The Difference between TypeScript Interfaces and Types

Collapse
 
epidemian profile image
Demian Ferreiro • Edited

Point 5, "Classes can implement interfaces, but not types", is not correct. IDK if it was the case on a previous version of TypeScript, but at least in the current one (4.8) the example with the createUser class works the same if you change the interface user to be type user instead:

type user = {
    name: string;
    age: number;
}

class createUser implements user {
  name = "John";
  age = 143;
}
Enter fullscreen mode Exit fullscreen mode

Link to TS Playground

Collapse
 
smpnjn profile image
Johnny Simpson • Edited

thanks - this must be new since older versions don't allow for this - and I assumed it was still the case. I'll update the article