npm install --save @lottie-animation-community/lottie-typesThis package contains type definitions and runtime constants for the Lottie animation format, with dedicated ESM and CommonJS entry points.
import { BlendMode, LayerType } from "@lottie-animation-community/lottie-types";
const blendMode: BlendMode = BlendMode.Normal;
const layerType: LayerType = LayerType.Text;const { BlendMode } = require("@lottie-animation-community/lottie-types");The deprecated uppercase enum names remain available for compatibility:
const blendMode: BlendMode.VALUE = BlendMode.VALUE.NORMAL;Since the constants exist at runtime, install the package as a regular dependency (not a devDependency) if you use them as values rather than only as types.
The project has been migrated from the lottiefiles organization that has been used internally. The definition types have been built based on lottie-docs/schema with a few differences: firstly, some additional informative type comments have been added through testing the schema types with real Lottie data; secondly, the types constructed in a way to avoid duplications.
Instead of writing the types manually, generating it automatically was considered but wasn't successful, for reason that most of the tools such as quicktype, json-schema-to-typescript and transform don't work well with huge JSON-schema structures with many nested layers and don't support json-schema/draft/2020-12 features such as complicated conditionals, prefixItems, and some def reference scenarios.
The schema definitions have been synced with marcusstenbeck/lottie-types as well.
- auto-generate types from lottie-docs/schema
- publish the final definition bundle to DefinitelyTyped
The following steps will get you setup to contribute changes to this repo:
-
Fork the repo
-
Run
yarn installto get dependencies packages -
Sync any schema changes with lottie-docs
-
Add changesets running
yarn changelogfor any reasonable change to your codebase. You must ensure Changesets are included when making a Pull Request to merge to main branches. Please refer to the changeset docs -
Create a PR from
feature-branchtomain -
After merging to
mainthe Github action will create another PR for only version bumping and changelog, which you have to merge the PR manually -
the package will be released to the NPM and GitHub registry after the merging the Changeset PR
| Command | Description |
|---|---|
yarn clean |
Deletes the generated package entry points |
yarn test |
Builds and validates types plus ESM and CommonJS runtime exports |
yarn format:prettier |
Format the code using prettier |
yarn build |
Bundles runtime constants and declarations into package entry points |
yarn changelog |
Add a changeset changelog entry |
yarn changelog:check |
Check pending changesets |
yarn changelog:version |
Update all the workspace projects versions using changesets |
yarn changelog:publish |
Publish the packages to the package repository |