我想使用IdleDetector,但是Typescript没有类型,如果说Cannot find name 'IdleDetector',我该怎么办?
IdleDetector
Cannot find name 'IdleDetector'
vs3odd8k1#
您可以将以下内容添加到global.d.ts:
global.d.ts
interface IdleDetector { addEventListener(type: "change", listener: (this: IdleDetector, ev: { userState: "active" | "idle", screenState: "locked" | "unlocked" }) => unknown, options?: boolean | AddEventListenerOptions): void; start(options: { threshold: number }): Promise<void>; screenState: "locked" | "unlocked"; userState: "active" | "idle"; } declare const IdleDetector: { new(): IdleDetector; requestPermission(): Promise<"granted" | "denied">; };
它不是100%正确,但对我来说已经足够好了。
1条答案
按热度按时间vs3odd8k1#
您可以将以下内容添加到
global.d.ts
:它不是100%正确,但对我来说已经足够好了。