DEV Community

Discussion on: Learn about difference between Type & Interface in Typescript

Collapse
 
faiwer profile image
Stepan Zubashev

What interface can do, and what type cant do. A class can implement an interface

type A = { a: number };
class B implements A { 
  a: number = 1; 
}
Enter fullscreen mode Exit fullscreen mode

no errors

Collapse
 
codeoz profile image
Code Oz

Hey ! thank you for your comment, I miss something wrong since a few time, this is available ! I edit my article thank you :)

Collapse
 
fullstackchris profile image
Chris Frewin

Coming from somewhere like C# a class implementing a type is kind of... weird... Though, all instances of a class automatically are that type... so it makes sense in a weird way too.

Some comments have been hidden by the post's author - find out more