npm.io
0.5.6 • Published 2d ago

typed-config-plugins

Licence
MIT
Version
0.5.6
Deps
0
Size
97 kB
Vulns
0
Weekly
0
Stars
1

typed-config-plugins npm npm

Type-safe helpers for Expo config plugins in app.config.ts.

typed-config-plugins gives you autocomplete and option validation for Expo config plugins so you can stop guessing the shape of plugin options in your config.

What It Does

  • Adds typed plugin helpers for Expo config authoring
  • Ships generated typings for many common third-party plugins
  • Lets you extend missing plugin types with module augmentation
  • Works with normal Expo config output and only changes authoring ergonomics

JSON config files cannot be type-checked. Use app.config.ts if you want the full benefit of this package.

Install

npm install typed-config-plugins

Quick Start

import { type ConfigContext, type ExpoConfig } from "expo/config";
import { plugin } from "typed-config-plugins";

export default ({ config }: ConfigContext): ExpoConfig => ({
  ...config,
  plugins: [
    plugin("expo-build-properties", {
      android: { minSdkVersion: 26 }
    }),

    // Regular Expo syntax still works too:
    ["expo-build-properties", { android: { minSdkVersion: 26 } }]
  ]
});

Extend Missing Plugin Types

If a plugin is not covered yet, add your own typings with module augmentation:

import "typed-config-plugins";

declare module "typed-config-plugins" {
  interface ThirdPartyPlugins {
    "demo-package": {
      bar: string;
      baz?: number;
    };
  }
}

Now plugin("demo-package", { ... }) will be type-checked in app.config.ts.

Good Fit

  • You already use app.config.ts
  • You want autocomplete for plugin options
  • You maintain custom or third-party config plugins
  • You want TypeScript errors before expo prebuild

Keywords