You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library mocks the After Effects expressions API in TypeScript, providing types and the available global functions and variables.
4
+
5
+
> To be used with [rollup-plugin-ae-jsx](https://www.npmjs.com/package/rollup-plugin-ae-jsx), which will convert the code to After Effects friendly `.jsx` files and remove the globals imported from this package.
Found in our [Expressions Library Template](https://github.com/motiondeveloper/expressions-library-template).
16
+
17
+
2. Import globals functions as needed
18
+
19
+
```js
20
+
import {
21
+
timeToFrames,
22
+
add,
23
+
length,
24
+
random,
25
+
} from"expression-globals-typescript";
26
+
```
27
+
28
+
3. Import object bases to create layer, comp, and property mocks
29
+
30
+
```js
31
+
import {
32
+
PropertyBase,
33
+
LayerBase,
34
+
CompBase,
35
+
} from"expression-globals-typescript";
36
+
37
+
constthisProperty=Object.create(PropertyBase);
38
+
constthisLayer=Object.create(LayerBase);
39
+
constthisComp=Object.create(CompBase);
40
+
```
41
+
42
+
You can then use the properties and methods of these objects as you would within expressions.
43
+
44
+
## Why?
45
+
46
+
When writing expressions in **Typescript** using our [Expressions Library Template](https://github.com/motiondeveloper/expressions-library-template) and [rollup-plugin-ae-jsx](https://www.npmjs.com/package/rollup-plugin-ae-jsx), TypeScript will complain if you try to use the global functions and objects available in expressions.
47
+
48
+
This is because they aren't defined in the development environment.
49
+
50
+
`expression-globals-typescript` solves this by mocking the entire expressions API in TypeScript, so you can import and use these globals, with the advantages of them being fully typed.
0 commit comments