Defining Intersection Types

[!INFO]-
topic: πŸ¦’ TypeScript
links: Defining union types
source: TypeScript course by the native web
tags: #permanent-noteΒ #published

Last Modified: =dateformat(this.file.mtime, "MMM. dd, yyyy - HH:mm")


Analog to union types, you can merge types together with &.

interface CanBreathe {
  breathe: () => void;
}

interface CanTalk {
  talk: () => void;
}

const foo = function (human: CanBreathe & CanTalk): void {
  human.breathe();
  human.talk();
};

export {};