Function
type EatType = (food: string) => void;
interface IEat {
(food: string): void;
}
Array
type PersonList = string[];
interface IPersonList {
[index: number]: string;
}
intersection
interface ErrorHandling {
success: bloolean;
error?: { message: string };
}
interface ArtistsData {
artists: { name: string }[];
}
type ArtistsResponseType = ArtistsData & ErrorHandliing;
interface IArtistsResponse extends ArtistsData, ErrorHandling {}
let art: ArtistsResponseType;
let iar: IArtistsResponse;
union types
interface Bird {
fly(): void;
layEggs(): void;
}
interface Fish {
swim(): void;
layEggs(): void;
}
type PetType = Bird | Fish;
interface IPet extends PetType {}
class Pet implements PetType {}
Declaration Merging - interface
interface MergingInterface {
a: string;
}
interface MergingInterface {
b: string;
}
let mi: MergingInterface;
mi.
Declaration Merging - type alias
type MergingType = {
a: string;
};
type MergingType = {
b: string;
};