SelectProps 의 T 는 single 또는 multiple 이고 기본값은 multiple 이다. SelectProps 라고만 쓰면 T 가 multiple 로 정해져 value 가 string[] 이 되고, SelectProps<single> 로 명시하면 value 가 string 이 된다. 기본값은 제약(single | multiple)을 만족해야 한다. 가장 자주 쓰는 경우를 기본값으로 두면 매번 제네릭을 적지 않아도 된다.

-- 제네릭 기본값: <T extends Type = Default>. 생략하면 기본값, 기본값은 제약을 만족해야 한다
type Mode = 'single' | 'multiple'
type SelectProps (t :: Mode = 'Multiple') = { mode :: t, value :: Value t }

type family Value t where
  Value 'Single   = String
  Value 'Multiple = [String]

a :: SelectProps                  -- t = 'Multiple
a = { mode = Multiple, value = ["a", "b"] }
b :: SelectProps 'Single
b = { mode = Single, value = "a" }

-- 매개변수마다 기본값
type ApiResponse (d = Any) (s :: Status = 'Loading) = { data' :: If (s == 'Success) d Null, status :: s }
-- 가장 자주 쓰는 경우를 기본값으로 — 매번 적지 않는다

출처

`#516`