Creating an object using the vs class interface in Typescript (Angular 5) against Java and C #

I want to understand using the vs class interface to create a model in angular 2. When we create a model in Java or C #, we use model classes to represent the data model that runs in our application and is therefore strongly typed.

//C#
public class Movie 
{
   public int ID { get; set; }
   public string Title { get; set; }
   public DateTime ReleaseDate { get; set; }
   public string Genre { get; set; }
   public decimal Price { get; set; }
}

In most cases, we will adhere to data binding with this model to databases based on our requirements.

I see examples and tutorials using the same methods as this.

//Java
public class Movie
{
   public int ID;
   public String Title;
   public Date ReleaseDate;
   public String Genre;
   public float Price;
}

Then I start using angular and typescript for web development. I find that some people like to use the interface to represent their model, while others like to stick to the class.

//Class
export class Movie {
    public string id;
    public string title;
    public Date ReleaseDate;
    public string Genre;
    public number
}
//Interface
export interface Movie {
    public string id;
    public string title;
    public Date ReleaseDate;
    public string Genre;
    public number
}

However, when it comes to creating and using a model, it looks like me.

 //declare
let movie = new Movie();
movie: Movie = new Movie();
movies: Movie[];
amovie: Movie;
//reactive
obsMovies: Observable<Movie[]>;
obsAMovie: Observable<Movie>;

, typescript. - , , , .

+6
1

Typescript Java #. JavaScript.

- . . Typescript -Interfaces .

, , Typecipt .

+7

All Articles