Like an if-else in logic — "if T matches this shape, give type X, otherwise type Y".
Conditional types work like ternary operators for types. IsString<string> evaluates to true because string extends string.
> IsString<string> = true > IsString<number> = false > IsString<"literal"> = true (string literals extend string)
Like an if-else in logic — "if T matches this shape, give type X, otherwise type Y".
Conditional types work like ternary operators for types. IsString<string> evaluates to true because string extends string.
> IsString<string> = true > IsString<number> = false > IsString<"literal"> = true (string literals extend string)
Sign in to cast your vote
Sign in to share your feedback and join the discussion.