Open3

実装Memo(TypeScript)

chocolatchocolat

型を組み合わせる

interface SomeProps {
    some: string;
    other: number;
};

function OfficeSection({
    some,
    other,
    additional,
}: SomeProps & { additional: boolean }): ReactElement {
    return (
        <> ... </>
    );
}
chocolatchocolat

read only

as const と宣言するとread onlyとして扱われる

const someThing = {
  name: "John",
  age: 35
} as const;
chocolatchocolat

Union 型と Generic 型

# Union 型
interface Props {
  items: Fruit[] | Snac[]
}

// => (Fruit | Snac)[]

# Generic 型
interface Props<T> {
  items: T[]
}

// => Fruit[] | Snac[]