Interfaces

An interface can be used to represent the shape of an custom object-like data structure.


export interface myInterface { 
   property_id: number,
   property_name: string,
   property_hasPurchased: boolean,
}


with Optional Properties

Interface members can be optional (using a question mark)

export interface myInterface { 
   property_description?: string,
}


with Read-Only Properties


interface Point { 
   readonly property_id: number;
}


with Methods/Functions


export interface myInterface { 
   property_id: number,
   property_name: string,
   property_hasPurchased: boolean,
   property_description?: string,
   method_makeOrder(id: number): boolean,
}



© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext