• Blog
  • Changelog
  • Follow us on GitHubFollow us on XJoin our Discord server
  • Blog
  • GitHub
  • Releases
  • Getting started

    • Overview
  • Library

    • Getting started
    • Array
    • Result
    • Dependency injection
    • Resource management
    • Task
    • Type
    • Conventions
  • Local-first

    • Getting started
    • Playgrounds
    • Examples
    • Owners
    • Relay
    • Migrations
    • Time travel
    • Indexes
    • Protocol
    • Privacy
    • FAQ
  • Other

    • API reference
    • Comparison
    • Showcase
    • Changelog

API reference › @evolu/common › Type › literal

function literal<T>(expected: T): LiteralType<T>;

Defined in: packages/common/src/Type.ts:2411

Literal Type.

https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types

Example

const LiteralHello = literal("Hello");
const result = LiteralHello.from("Hello"); // ok("Hello")
const errorResult = LiteralHello.from("World"); // err

TODO: Add JsonValue

Markdown for LLMs

© 2026 Evolu

Follow us on GitHubFollow us on XJoin our Discord server