UNPKG

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