最終更新:2022-08-25 (木) 19:47:59 (609d)  

TypeScript/&
Top / TypeScript / &

Intersection Types

https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html

例1

  • type ManagerEmploee? = Admin & Employee;

例2

  • ItemForm?は以下の4つのプロパティを全て持つ
    • id
    • title
    • body
    • edit
    type Item = {
      id: string;
      title: string;
      body: string;
    };
    
    
    type ItemForm = Item & {
      edit: boolean;
    };

参考