Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-dts-type-pollution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/react-query-devtools': patch
---

fix(build): exclude config files from production DTS rollup to prevent `@types/node` type pollution
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
"scripts": {
"clean": "pnpm --filter \"./packages/**\" run clean",
"test": "pnpm run test:ci",
"test:pr": "nx affected --targets=test:sherif,test:knip,test:docs,test:eslint,test:lib,test:types,test:build,build",
"test:ci": "nx run-many --targets=test:sherif,test:knip,test:docs,test:eslint,test:lib,test:types,test:build,build",
"test:pr": "nx affected --targets=test:sherif,test:knip,test:docs,test:eslint,test:lib,test:types,test:build,build && pnpm run test:build:dts",
"test:ci": "nx run-many --targets=test:sherif,test:knip,test:docs,test:eslint,test:lib,test:types,test:build,build && pnpm run test:build:dts",
"test:eslint": "nx affected --target=test:eslint",
"test:sherif": "sherif -i typescript -p \"./integrations/*\" -p \"./examples/*\"",
"test:size": "size-limit",
"test:lib": "nx affected --target=test:lib --exclude=examples/**",
"test:lib:dev": "pnpm run test:lib && nx watch --all -- pnpm run test:lib",
"test:build": "nx affected --target=test:build --exclude=examples/**",
"test:build:dts": "node scripts/verify-dts-imports.ts",
"test:types": "nx affected --target=test:types --exclude=examples/**",
"test:knip": "knip --treat-config-hints-as-errors",
"test:docs": "node scripts/verify-links.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/angular-query-experimental/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"composite": false,
"rootDir": "../../",
"customConditions": null
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/angular-query-persist-client/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/eslint-plugin-query/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/preact-query-devtools/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"composite": false,
"rootDir": "../../",
"customConditions": []
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/preact-query-persist-client/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/query-async-storage-persister/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/query-devtools/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/query-persist-client-core/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/query-sync-storage-persister/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/react-query-devtools/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"composite": false,
"rootDir": "../../",
"customConditions": []
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/react-query-next-experimental/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/react-query-persist-client/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/solid-query-devtools/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/solid-query-persist-client/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
4 changes: 3 additions & 1 deletion packages/vue-query/tsconfig.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"incremental": false,
"composite": false,
"rootDir": "../../"
}
},
"include": ["src"],
"exclude": ["src/__tests__"]
}
54 changes: 54 additions & 0 deletions scripts/verify-dts-imports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { readFileSync } from 'node:fs'
import { glob } from 'tinyglobby'

const FORBIDDEN_PATTERNS = [
/\bfrom\s+['"]vite['"]/,
/\bfrom\s+['"]tsup['"]/,
/\bfrom\s+['"]vitest/,
/\/\/\/\s*<reference\s+types=["']node["']\s*\/>/,
]

const errors: Array<{ file: string; line: number; text: string }> = []

const files = await glob(['packages/*/build/**/*.d.ts', 'packages/*/build/**/*.d.cts'])

if (files.length === 0) {
console.error(
'ERROR: No declaration files found under packages/*/build. Ensure the build step produced .d.ts outputs before verification.',
)
process.exit(1)
}

for (const file of files) {
const content = readFileSync(file, 'utf-8')
const lines = content.split('\n')
for (let i = 0; i < lines.length; i++) {
const line = lines[i]!
for (const pattern of FORBIDDEN_PATTERNS) {
if (pattern.test(line)) {
errors.push({ file, line: i + 1, text: line.trim() })
}
}
}
}

if (errors.length > 0) {
console.error(
'ERROR: Build tool types leaked into published .d.ts files:\n',
)
for (const error of errors) {
console.error(` ${error.file}:${error.line}`)
console.error(` ${error.text}\n`)
}
console.error(
'This usually means a tsconfig.prod.json is missing "include": ["src"].',
)
console.error(
'See https://github.com/TanStack/query/issues/10294 for details.',
)
process.exit(1)
} else {
console.log(
`Verified ${files.length} declaration files (.d.ts/.d.cts) — no build tool type leaks found.`,
)
}