【发布时间】:2020-06-08 08:26:00
【问题描述】:
我想用下面的代码声明 window.lottie。
// node_modules/lottie-web/index.d.ts
type LottiePlayer = {
play(name?: string): void;
stop(name?: string): void;
setSpeed(speed: number, name?: string): void;
setDirection(direction: AnimationDirection, name?: string): void;
searchAnimations(animationData?: any, standalone?: boolean, renderer?: string): void;
loadAnimation(params: AnimationConfigWithPath | AnimationConfigWithData): AnimationItem;
destroy(name?: string): void;
registerAnimation(element: Element, animationData?: any): void;
setQuality(quality: string | number): void;
setLocationHref(href: string): void;
};
declare const Lottie: LottiePlayer;
export default Lottie;
//src/type.d.ts
import Lottie from 'lottie-web';
declare interface Window {
lottie: Lottie;
}
但是有一个错误。
TS2749: 'Lottie' refers to a value, but is being used as a type here.
那么如何在 TypeScript 中导入默认导出类型呢?
【问题讨论】:
标签: typescript