--!strict export type StateData = { Get: (self: StateData) -> T } export type State = StateData & { Apply: (self: State, factory: (State) -> U) -> U, } local s: State = nil :: any type GateFactory = typeof(setmetatable( {} :: { Flush: () -> (), Cancel: () -> () }, {} :: { __call: (any, State) -> State } )) local Debounced: GateFactory = nil :: any -- (A) 제네릭이 아닌 평범한 함수 파라미터 자리에도 안 들어가는가? local function takesFn(f: (State) -> State) return f(s) end local a = takesFn(Debounced) -- (B) 유니온으로 열면 되는가 local function takesEither(f: ((State) -> State) | GateFactory) return (f :: any)(s) end local b = takesEither(Debounced) local b2 = takesEither(function(x: State) return x end)