assert Function

Asserts that a condition is true, and in development builds throws an error if it is not. This is an assertion function that alters the behavior of the TypeScript compiler.

assert(condition: boolean, msg?: string): condition

throws Error containing the specified message if condition is false.

note This function should be used to validate conditions that should never realistically occur, or which indicate a misuse of the API which should be eliminated during development.

Parameter Type Description
condition boolean The result of a boolean expression.
msg string An optional message to include in the thrown exception. Defaults to "Programmer Error".

Returns - condition

Defined in

Last Updated: 31 March, 2021