unknown (type)

The type-safe type for a value that could be anything, which you must narrow before you can use it.

In more detail

Like any, unknown accepts every value, but unlike any it forbids reading properties or calling it until a check proves what it is. It is the right type for network payloads, parsed JSON, storage and caught errors.

Example

function parseWebhook(raw: unknown): WebhookEvent

Related terms

Taught in

References