Function getRuntimeType

  • Determines the RuntimeType of a variable. This is similar to the built-in typeof operator except in the following ways:

    • This returns an enum value (RuntimeType) rather than just a string (though the enum values are strings anyway).
    • This includes new types array and null, that typeof does not have, which are both distinct from object.

    Parameters

    • actual: unknown

    Returns RuntimeType

    import {getRuntimeType} from '@augment-vir/assert';

    getRuntimeType(['a']); // RuntimeType.Array
    getRuntimeType({a: 'a'}); // RuntimeType.Object

    @augment-vir/assert