Choose a type based on another type relationship.
Section: Mapped and Conditional Types
Conditional type
typescript
typescript
type IsString<T> = T extends string ? true : false;Explanation
Conditional types are the basis for many advanced utility helpers.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Mapped and Conditional Types
Discriminated union pattern
Model variant objects with a shared discriminant field.
Generic identity function
Use a type parameter for reusable function typing.