## Description - Enabled the rule `@typescript-eslint/no-explicit-any` - Suppressed errors with comment ``` // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any ``` Fixes #35308 ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10181176984> > Commit: 7fc604e24fa234da7ab2ff56e0b1c715268796ee > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10181176984&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Wed, 31 Jul 2024 15:00:45 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import type {
|
||
AnimationConfigWithPath,
|
||
AnimationItem,
|
||
LottiePlayer,
|
||
} from "lottie-web";
|
||
|
||
let cachedLottie: LottiePlayer | null = null;
|
||
|
||
export type LazyAnimationItem = Pick<
|
||
AnimationItem,
|
||
"play" | "addEventListener" | "destroy" | "goToAndStop"
|
||
>;
|
||
|
||
const lazyLottie = {
|
||
loadAnimation: (
|
||
// Note: explicitly not using the `AnimationConfigWithData` type here because we want all animations
|
||
// to be passed as URLs (`path: ...`), not as objects (`animationData: ...`). To pass an animation as an object,
|
||
// you need to bundle it, which makes the bundle larger.
|
||
//
|
||
// If you’re a developer who wants to play a Lottie animation, please import the animation as a `.txt` file:
|
||
//
|
||
// import animationURL from "./animation.json.txt";
|
||
//
|
||
// and pass it as the `path` prop:
|
||
//
|
||
// lazyLottie.loadAnimation({ path: animationURL, ... });
|
||
params: AnimationConfigWithPath,
|
||
): LazyAnimationItem => {
|
||
if (cachedLottie) {
|
||
return cachedLottie.loadAnimation(params);
|
||
}
|
||
|
||
const abortController = new AbortController();
|
||
const queuedCommands: Array<{
|
||
commandName: "play" | "addEventListener" | "goToAndStop";
|
||
// TODO: Fix this the next time the file is edited
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||
args: any[];
|
||
}> = [];
|
||
|
||
import("lottie-web").then(({ default: lottie }) => {
|
||
if (abortController.signal.aborted) {
|
||
return;
|
||
}
|
||
|
||
cachedLottie = lottie;
|
||
const animation = lottie.loadAnimation(params);
|
||
for (const command of queuedCommands) {
|
||
// @ts-expect-error – Getting “A spread argument must either have a tuple type or be passed to a rest parameter”, and it’s tricky to work around with this generalized code
|
||
// TODO: Fix this the next time the file is edited
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||
animation[command.commandName](...(command.args as any));
|
||
}
|
||
});
|
||
|
||
return {
|
||
play(...args) {
|
||
queuedCommands.push({ commandName: "play", args });
|
||
},
|
||
addEventListener(...args) {
|
||
queuedCommands.push({ commandName: "addEventListener", args });
|
||
|
||
return () => {
|
||
throw new Error("Not implemented");
|
||
};
|
||
},
|
||
goToAndStop(...args) {
|
||
queuedCommands.push({ commandName: "goToAndStop", args });
|
||
},
|
||
destroy() {
|
||
abortController.abort();
|
||
},
|
||
};
|
||
},
|
||
};
|
||
|
||
export default lazyLottie;
|