Function: defineFact()

August 8, 2026 ยท View on GitHub

@plures/praxis


@plures/praxis / index / defineFact

Function: defineFact()

defineFact<TTag, TPayload>(tag): FactDefinition<TTag, TPayload>

Defined in: src/dsl/index.ts:40

Define a typed fact

Type Parameters

TTag

TTag extends string

TPayload

TPayload

Parameters

tag

TTag

The fact type tag (e.g. "UserLoggedIn") โ€” must be a string literal type for full type safety

Returns

FactDefinition<TTag, TPayload>

A FactDefinition with create() and is() helpers

Example

const UserLoggedIn = defineFact<"UserLoggedIn", { userId: string }>("UserLoggedIn");
const fact = UserLoggedIn.create({ userId: "123" });
if (UserLoggedIn.is(fact)) {
  console.log(fact.payload.userId); // Type-safe!
}