TypeScript
Type Guards API Reference
TypeScript type guards for narrowing types at runtime.
By EZ4Code Team
Type Guards
Runtime checks that narrow types in conditional branches.
typeof x === 'string'Narrow primitive types using the typeof operator. Recognized: 'string', 'number', 'boolean', 'bigint', 'symbol', 'undefined', 'object', 'function'.
Returns: boolean
x instanceof ClassNarrow to an instance type by checking the prototype chain.
Returns: boolean
'key' in objNarrow a union type by checking for the presence of a property.
Returns: boolean
function isX(x: any): x is TUser-defined type guard. The 'x is T' return type predicate triggers narrowing when the function returns true.
Returns: x is T