TypeScript Types

The generated index.d.ts is self-contained — import concrete types directly.

@drasi/lib ships first-class TypeScript support. The generated index.d.ts is self-contained: every config parameter, result, return value, and callback payload is exposed with a concrete type — no bare any — so you get full editor completion and type-checking out of the box.

Import types directly

import type { SourceChangeInput, QueryResultEvent } from '@drasi/lib';

const change: SourceChangeInput = { op: 'insert', id: 'o1', labels: ['Order'] };

const onResult = (event: QueryResultEvent) => console.log(event.results.length);

Types you’ll use most

TypeWhere it appears
CreateOptionsDrasi.create(id, options)
DrasiConfigDrasi.fromConfig(config)
SourceChangeInputpushChange(sourceId, change)
QueryJointhe joins argument to addQuery / updateQuery
QueryResultEvent, ResultDiffJS reaction callbacks
LogMessage, ComponentEventstreaming callbacks
QueryMetrics, ReactionQueryMetrics, LifecycleMetricsthe metrics accessors
ComponentStatusEntrylistSources / listQueries / listReactions
DrasiErrorCodetyped error handling (a real runtime enum)

DrasiErrorCode is a real value, not just a type

Unlike the shape types above, DrasiErrorCode is exported as a regular (non-const) enum with string values, so you can import it as a value and compare against it at runtime — safe under isolatedModules, esbuild, swc, and Vite:

import { DrasiErrorCode } from '@drasi/lib';

if (code === DrasiErrorCode.UnknownSourceKind) { /* ... */ }

See Error handling for the full pattern.

Type-checking the definitions

The repository type-checks its own .d.ts in CI under --strict --isolatedModules. If you’re contributing, you can run the same check:

npm run test:types

Next