typeid

View sourcetypeid(type: ConstructorFn): TypeId

Derives a TypeId lookup key from a constructor’s runtime name.

The constructor is not instantiated or inspected beyond its .name property, so the returned ID is exactly that name. Use the result with APIs that register or look up metadata for the constructor’s type. The result can differ after minification or if a constructor’s name is changed. Use setTypeId for types without a runtime constructor.

Examples

class Position {}
const positionId = typeid(Position)
// positionId === 'Position'

Parameters

NameDescriptionDefault
type

The constructor whose runtime name identifies the type.

—

Returns

The constructor’s .name value marked as a TypeId.