TS v4.4 brought in modifications to lib dom type defintions (reference).
These conflict with the types declared for requestIdleCallback and cancelIdleCallback on global window here:
declare global {
const requestIdleCallback: (
callback: (deadline: RequestIdleCallbackDeadline) => void,
opts?: RequestIdleCallbackOptions,
) => RequestIdleCallbackHandle;
const cancelIdleCallback: (handle: RequestIdleCallbackHandle) => void;
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
requestIdleCallback: typeof requestIdleCallback;
cancelIdleCallback: typeof cancelIdleCallback;
}
}
The above results in below errors during build:
node_modules/react-vtree/dist/es/utils.d.ts:16:11 - error TS2451: Cannot redeclare block-scoped variable 'requestIdleCallback'.
16 const requestIdleCallback: (callback: (deadline: RequestIdleCallbackDeadline) => void, opts?: RequestIdleCallbackOptions) => RequestIdleCallbackHandle;
~~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:17772:18
17772 declare function requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
~~~~~~~~~~~~~~~~~~~
'requestIdleCallback' was also declared here.
node_modules/react-vtree/dist/es/utils.d.ts:17:11 - error TS2451: Cannot redeclare block-scoped variable 'cancelIdleCallback'.
17 const cancelIdleCallback: (handle: RequestIdleCallbackHandle) => void;
~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:17741:18
17741 declare function cancelIdleCallback(handle: number): void;
~~~~~~~~~~~~~~~~~~
'cancelIdleCallback' was also declared here.
I am unable to use later TS version because of this error, can we drop the redundant type declarations in favor of native support (I don't think upgrading TS version breaks anything within the library)?
Alternatively can someone suggest how can I override types here as a workaround?
TS v4.4 brought in modifications to lib dom type defintions (reference).
These conflict with the types declared for
requestIdleCallbackandcancelIdleCallbackon global window here:The above results in below errors during build:
I am unable to use later TS version because of this error, can we drop the redundant type declarations in favor of native support (I don't think upgrading TS version breaks anything within the library)?
Alternatively can someone suggest how can I override types here as a workaround?