Skip to content

Type Augmentation

Extend PikaCSS TypeScript interfaces so your plugin's configuration options get full type checking and autocomplete.

EngineConfig

Augment the EngineConfig interface to add plugin-specific configuration fields:

ts
declare module '@pikacss/core' {
  interface EngineConfig {
    /** My plugin's configuration */
    myPlugin?: {
      enabled?: boolean
      theme?: 'light' | 'dark'
    }
  }
}

After augmentation, users get autocomplete when configuring the engine:

ts
defineEngineConfig({
  plugins: [myPlugin()],
  myPlugin: {
    enabled: true, // ✅ autocomplete works
    theme: 'dark', // ✅ type-checked
  },
})

Engine

Augment the Engine interface to add methods or properties to engine instances:

ts
declare module '@pikacss/core' {
  interface Engine {
    /** Custom method added by my plugin */
    getTheme: () => string
  }
}

Then in your configureEngine hook:

ts
defineEnginePlugin({
  name: 'my-plugin',
  configureEngine: (engine) => {
    engine.getTheme = () => 'dark'
  },
})

PikaAugment

The PikaAugment namespace provides type-level extension points for the autocomplete system. Plugins can register custom selectors, shortcuts, properties, and property values:

ts
declare module '@pikacss/core' {
  namespace PikaAugment {
    interface Autocomplete {
      Selector: '@my-selector'
      Shortcut: 'my-shortcut'
    }
  }
}

This ensures that custom selectors and shortcuts defined by your plugin appear in IDE autocomplete suggestions within style definitions.

Next