tstype X = "A" | "B"; const f = (x: X): X => (x); const a: "A" = f("A"); // error
tsconst f = <T extends X>(x: T): T => (x); const a: "A" = f("A"); // ok