typed-config-plugins 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +40 -36
  2. package/dist/plugin.d.ts +206 -225
  3. package/package.json +32 -19
package/README.md CHANGED
@@ -1,64 +1,68 @@
1
1
  # typed-config-plugins [![npm][npm-image]][npm-url] ![npm][npm-dl-stats]
2
2
 
3
- **Type Safety for Your Expo Config Plugins.**
3
+ Type-safe helpers for Expo config plugins in `app.config.ts`.
4
4
 
5
- Expo config plugins are incredibly powerful, but their configuration lacks the safety net of type checking. `typed-config-plugins` bridges this gap, bringing the full power of TypeScript to your Expo project's configuration.
5
+ `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.
6
6
 
7
- ## Features
7
+ ## What It Does
8
8
 
9
- - **Enhanced Developer Experience:** Get autocomplete and type validation directly in your `app.config.ts` files, making plugin configuration less error-prone and more efficient.
10
- - **Pre-built Types:** Includes ready-to-use TypeScript definitions for many popular Expo config plugins, generated by analyzing their source code.
11
- - **Extensible:** Easily add custom types for your own or third-party plugins using TypeScript module augmentation.
12
- - **Seamless Integration:** Designed to work smoothly with your existing `app.config.ts` setup. **Note: JSON config files are not supported.**
9
+ - Adds typed plugin helpers for Expo config authoring
10
+ - Ships generated typings for many common third-party plugins
11
+ - Lets you extend missing plugin types with module augmentation
12
+ - Works with normal Expo config output and only changes authoring ergonomics
13
13
 
14
- ## 📦 Installation
14
+ > JSON config files cannot be type-checked. Use `app.config.ts` if you want the full benefit of this package.
15
+
16
+ ## Install
15
17
 
16
18
  ```bash
17
- npm i typed-config-plugins
19
+ npm install typed-config-plugins
18
20
  ```
19
21
 
20
- ## 🚀 Usage
21
-
22
- Update your `app.config.ts` file to use the `plugin` helper from `typed-config-plugins`.
22
+ ## Quick Start
23
23
 
24
- ```typescript
24
+ ```ts
25
25
  import { type ConfigContext, type ExpoConfig } from "expo/config";
26
26
  import { plugin } from "typed-config-plugins";
27
27
 
28
28
  export default ({ config }: ConfigContext): ExpoConfig => ({
29
- ...config,
30
- // ... other config
31
- plugins: [
32
- // typed syntax by this package (with type checking/autocompletion):
33
- plugin("expo-build-properties", { android: { minSdkVersion: 26 } }),
34
-
35
- // normal syntax (no type checking/autocompletion):
36
- ["expo-build-properties", { android: { minSdkVersion: 26 } }],
37
- ],
29
+ ...config,
30
+ plugins: [
31
+ plugin("expo-build-properties", {
32
+ android: { minSdkVersion: 26 }
33
+ }),
34
+
35
+ // Regular Expo syntax still works too:
36
+ ["expo-build-properties", { android: { minSdkVersion: 26 } }]
37
+ ]
38
38
  });
39
39
  ```
40
40
 
41
- ## 🤝 Adding Custom Plugin Types
42
-
43
- To extend `typed-config-plugins` with types for your own plugins or plugins not yet covered, you can use TypeScript's module augmentation feature.
41
+ ## Extend Missing Plugin Types
44
42
 
45
- Create a new declaration file (e.g., `config-plugins.d.ts`) in your project's root or `src` directory with the following content:
43
+ If a plugin is not covered yet, add your own typings with module augmentation:
46
44
 
47
- ```typescript
48
- // config-plugins.d.ts
49
- import "typed-config-plugins"; // Import the original type declarations
45
+ ```ts
46
+ import "typed-config-plugins";
50
47
 
51
48
  declare module "typed-config-plugins" {
52
- // Extend the `ThirdPartyPlugins` interface with your custom plugin types
53
- interface ThirdPartyPlugins {
54
- // Define options for "demo-package" (as used in the example)
55
- "demo-package": { bar: string, baz?: number };
56
- // more packages here...
57
- }
49
+ interface ThirdPartyPlugins {
50
+ "demo-package": {
51
+ bar: string;
52
+ baz?: number;
53
+ };
54
+ }
58
55
  }
59
56
  ```
60
57
 
61
- Now, when you use `plugin("my-custom-plugin", { /* ... */ })` in your `app.config.ts`, TypeScript will provide autocompletion and validate the options against the types you've defined.
58
+ Now `plugin("demo-package", { ... })` will be type-checked in `app.config.ts`.
59
+
60
+ ## Good Fit
61
+
62
+ - You already use `app.config.ts`
63
+ - You want autocomplete for plugin options
64
+ - You maintain custom or third-party config plugins
65
+ - You want TypeScript errors before `expo prebuild`
62
66
 
63
67
  [npm-image]: https://img.shields.io/npm/v/typed-config-plugins
64
68
  [npm-url]: https://www.npmjs.com/package/typed-config-plugins