UNPKG

1.38 kBTypeScriptView Raw
1// Minimum TypeScript Version: 3.1
2
3/**
4 * While there is nothing in these typings that prevent it from running in TS 2.8 even,
5 * due to the complexity of the typings anything lower than TS 3.1 will only see
6 * Jimp as `any`. In order to test the strict versions of these types in our typing
7 * test suite, the version has been bumped to 3.1
8 */
9
10import {
11 Jimp as JimpType,
12 Bitmap,
13 RGB,
14 RGBA,
15 UnionToIntersection,
16 GetPluginVal,
17 GetPluginConst,
18 GetPluginEncoders,
19 GetPluginDecoders,
20 JimpConstructors,
21} from "@jimp/core";
22import typeFn from "@jimp/types";
23import pluginFn from "@jimp/plugins";
24
25type Types = ReturnType<typeof typeFn>;
26type Plugins = ReturnType<typeof pluginFn>;
27
28type IntersectedPluginTypes = UnionToIntersection<
29 GetPluginVal<Types> | GetPluginVal<Plugins>
30>;
31
32type IntersectedPluginConsts = UnionToIntersection<
33 GetPluginConst<Types> | GetPluginConst<Plugins>
34>;
35
36type IntersectedPluginEncoders = UnionToIntersection<
37 GetPluginEncoders<Types> | GetPluginEncoders<Plugins>
38>;
39
40type IntersectedPluginDecoders = UnionToIntersection<
41 GetPluginDecoders<Types> | GetPluginDecoders<Plugins>
42>;
43
44type Jimp = JimpType & IntersectedPluginTypes;
45
46declare const Jimp: JimpConstructors &
47 IntersectedPluginConsts & {
48 prototype: Jimp;
49 encoders: IntersectedPluginEncoders;
50 decoders: IntersectedPluginDecoders;
51 };
52
53export = Jimp;