diff --git a/packages/query-core/root.eslint.config.js b/packages/query-core/root.eslint.config.js index 35dedbe5a4a..28eedf69546 120000 --- a/packages/query-core/root.eslint.config.js +++ b/packages/query-core/root.eslint.config.js @@ -1 +1,2 @@ -../../eslint.config.js \ No newline at end of file +import config from '../../eslint.config.js' +export default config \ No newline at end of file diff --git a/packages/query-core/root.tsup.config.js b/packages/query-core/root.tsup.config.js index fb8e9add9a3..d566502ecc1 120000 --- a/packages/query-core/root.tsup.config.js +++ b/packages/query-core/root.tsup.config.js @@ -1 +1 @@ -../../scripts/getTsupConfig.js \ No newline at end of file +export * from '../../scripts/getTsupConfig.js' \ No newline at end of file diff --git a/packages/query-core/src/timeoutManager.ts b/packages/query-core/src/timeoutManager.ts index 97f0870eea2..0a0dee88bb7 100644 --- a/packages/query-core/src/timeoutManager.ts +++ b/packages/query-core/src/timeoutManager.ts @@ -28,9 +28,7 @@ export type TimeoutProvider = readonly clearInterval: (intervalId: TTimerId | undefined) => void } -export const defaultTimeoutProvider: TimeoutProvider< - ReturnType -> = { +export const defaultTimeoutProvider: TimeoutProvider = { // We need the wrapper function syntax below instead of direct references to // global setTimeout etc. // @@ -41,11 +39,18 @@ export const defaultTimeoutProvider: TimeoutProvider< // replace the global setTimeout (like tests) won't work since we'll already // have a hard reference to the original implementation at the time when this // file was imported. - setTimeout: (callback, delay) => setTimeout(callback, delay), - clearTimeout: (timeoutId) => clearTimeout(timeoutId), + // + // We cast the return values to `ManagedTimerId` to avoid leaking + // `ReturnType` into declaration files. When `@types/node` + // is present during compilation, `ReturnType` resolves to + // `NodeJS.Timeout`, which would inject Node.js types into browser consumers. + setTimeout: (callback, delay) => + setTimeout(callback, delay) as unknown as ManagedTimerId, + clearTimeout: (timeoutId) => clearTimeout(timeoutId as any), - setInterval: (callback, delay) => setInterval(callback, delay), - clearInterval: (intervalId) => clearInterval(intervalId), + setInterval: (callback, delay) => + setInterval(callback, delay) as unknown as ManagedTimerId, + clearInterval: (intervalId) => clearInterval(intervalId as any), } /**