Configuration

TypeScript

TypeScript configuration for OmniSvelte — generated ambient declarations and tsconfig setup.

TypeScript

OmniSvelte is built TypeScript-first. The Vite plugin generates ambient type declarations so all virtual module imports are fully typed.

Auto-generated: src/omni-env.d.ts

On the initial pnpm dev start (and during build), OmniSvelte writes this file — do not edit it manually:

ts
// src/omni-env.d.ts — auto-generated by omni-svelte
declare module '$models' {
  export * from '$lib/db/models/index';
}
declare module '$schema' {
  export * from '$lib/db/server/schema';
}
declare module '$validation' {
  export * from '$lib/db/validation/index';
}
declare module '$db' {
  import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
  export const db: PostgresJsDatabase;
}
declare module '$auth/server' {
  export const auth: import('better-auth').Auth;
}
declare module '$auth/client' {
  export const authClient: import('better-auth/client').BetterAuthClient;
}

This file is only updated when omni config options that would affect its content are updated

Sub-path shims

For individual model imports like $models/posts.model, add a test-env.d.ts at the project root:

ts
// test-env.d.ts
declare module '$models/posts.model' {
  export * from '$lib/db/models/posts.model'; // must use $lib/... not ./
}
declare module '$validation/posts.validation' {
  export * from '$lib/db/validation/posts.validation';
}

Include it in tsconfig.json:

json
{
  "extends": "./.svelte-kit/tsconfig.json",
  "include": ["test-env.d.ts", "src/**/*.ts", "src/**/*.svelte"]
}

Note: The need for this is currently being reviewed and would likely be adjusted shortly.

app.d.ts — SvelteKit ambient types

Extend SvelteKit's Locals to include OmniSvelte session data:

ts
// src/app.d.ts
declare global {
  namespace App {
    interface Locals {
      session: import('better-auth').Session | null;
      user:    import('better-auth').User | null;
    }
    interface PageData {}
    interface Error {}
    interface Platform {}
  }
}
export {};

Strict mode

OmniSvelte is designed to work with TypeScript strict mode. The generated model and validation types are fully strict-compatible. Add to tsconfig.json:

json
{
  "compilerOptions": {
    "strict": true,
    "moduleResolution": "bundler"
  }
}