Hyperlinkv0.8.0-beta.28

Context

Context.isContextconsteffect/Context.ts:565
(u: unknown): u is Context<never>

Checks whether the provided argument is a Context.

When to use

Use to narrow an unknown value before passing it to APIs that require a Context.

Details

This checks the runtime Context marker and does not inspect which services the context contains.

Gotchas

This guard only proves that the value is a Context; it does not prove that any specific service is present.

Example (Checking for contexts)

import { Context } from "effect"
import * as assert from "node:assert"

assert.strictEqual(Context.isContext(Context.empty()), true)
Source effect/Context.ts:5651 lines
export const isContext = (u: unknown): u is Context<never> => hasProperty(u, TypeId)
Referenced by 2 symbols