There is such an interface

export interface DataTransport { hand: Card[]; table: Card[]; status: boolean; score: number; round: number; finish: string; log: Log; } 

trying to check like that

 private isDefined() { return this.data.hand !== undefined && this.data.table !== undefined; } 

I know that you can somehow through instanceof or something else but there should be a normal solution.

 this.socket.on('info',(data: HeartsInterface.DataTransport) => { if(this.isDefined()){ console.log('BINGO'); } }); 
  • what does normal mean? What is not satisfied with the current implementation? - Grundy
  • @Grundy I want to check all the fields and that even the types match ideally - Serge Esmanovich
  • types coincided with what? - Grundy
  • @Grundy with the interface - Serge Esmanovich
  • at the interface with the interface? Try to expand the question, now it is not clear what exactly and when you want to check - Grundy

0