Union Type ๅˆ†้…ๅพ‹

ๅปบ็ซ‹๏ผš2026-05-19 ยท ๆœ€ๅพŒ็ทจ่ผฏ๏ผš2026-05-19
type IsString<T> = T extends string ? "yes" : "no";

type T = IsString<"a" | 2 | "c">; // "yes" | "no"

Union Type ๆ“ๆœ‰ๅˆ†้…็އ็š„็‰นๆ€ง๏ผš

type T = 
    | ("a" extends string ? "yes" : "no")
    | ( 2  extends string ? "yes" : "no")
    | ("c" extends string ? "yes" : "no");