Get the type of a value as a string.

import { getType } from '@aws-lambda-powertools/commons/typeUtils';

const type = getType('foo'); // 'string'
const otherType = getType(42); // 'number'
const anotherType = getType({ key: 'value' }); // 'object'
const unknownType = getType(Symbol('foo')); // 'unknown'
  • Parameters

    • value: unknown

      The value to check

    Returns string