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.
- package/README.md +40 -36
- package/dist/plugin.d.ts +206 -225
- 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
|
-
|
|
3
|
+
Type-safe helpers for Expo config plugins in `app.config.ts`.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
##
|
|
7
|
+
## What It Does
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
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
|
-
|
|
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
|
|
19
|
+
npm install typed-config-plugins
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
Update your `app.config.ts` file to use the `plugin` helper from `typed-config-plugins`.
|
|
22
|
+
## Quick Start
|
|
23
23
|
|
|
24
|
-
```
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
43
|
+
If a plugin is not covered yet, add your own typings with module augmentation:
|
|
46
44
|
|
|
47
|
-
```
|
|
48
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
interface ThirdPartyPlugins {
|
|
50
|
+
"demo-package": {
|
|
51
|
+
bar: string;
|
|
52
|
+
baz?: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
58
55
|
}
|
|
59
56
|
```
|
|
60
57
|
|
|
61
|
-
Now
|
|
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
|