Lesson 14 of 56
TypescriptType Guards & Discriminated Unions
20 minutes
Course progress25%
Type Guards
A type guard narrows a union type to a specific member.
function isString(x: unknown): x is string {
return typeof x === "string";
}
() {
((val)) {
.(val.());
} {
.(val.());
}
}