Skip to main content

cast

Cast variable to the desired type without type checking.

Signature

cast<T>(input: any): T

Parameters

NameTypeOptionalDescription
inputanyNoSpecifies the input.

Return value

Returns the desired type.

Example

// `an` has the `any` type.
const a: any = 1;

// `b` is now of type `number` and contains `1`.
const b = cast<number>(a);