Skip to content

@serenity-is/corelib / safeCast

Function: safeCast()

safeCast(instance, type): any

Defined in: src/compat/system-compat.ts:245

Attempts to cast instance to type, returning null on failure instead of throwing.

Parameters

instance

any

The value to cast.

type

Type

The target Type to test against.

Returns

any

instance if it is an instance of type; otherwise null.