Skip to content

Commit 2d5f5b6

Browse files
MFA-GKevinVandy
andauthored
fix(table-core): add export {} to declaration files without an export statement (#6620)
Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com>
1 parent ef60ec5 commit 2d5f5b6

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎.changeset/quiet-dts-exports.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/table-core': patch
3+
---
4+
5+
Keep private declarations out of the emitted `.d.ts` files, so consumers emitting declarations no longer fail with TS2883 (e.g. on `RangeValue`)

‎scripts/rewrite-table-core-dts.mjs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ function ensurePublicTypeImports(source, file) {
265265
return next
266266
}
267267

268+
// A declaration file without an export statement exports every top-level
269+
// declaration, including private helpers that are only reachable through deep
270+
// paths blocked by the package `exports` map. Consumers emitting declarations
271+
// then fail with TS2883 when an inferred type references one of them.
272+
// rolldown-plugin-dts 0.28.2+ inlines `export` modifiers and drops the
273+
// trailing `export { … }`, so restore the marker here.
274+
const exportStatementPattern = /^\s*export\s*(?:type\s*)?(?:\{[^}]*\}|\*|=)/m
275+
276+
function ensureExportStatement(source) {
277+
if (exportStatementPattern.test(source)) {
278+
return source
279+
}
280+
281+
return `${source.trimEnd()}\nexport {};\n`
282+
}
283+
268284
function rewriteDeclaration(source, file) {
269285
let next = source
270286

@@ -282,6 +298,7 @@ function rewriteDeclaration(source, file) {
282298
next = next.replaceAll('Column_Internal', 'Column')
283299

284300
next = ensurePublicTypeImports(next, file)
301+
next = ensureExportStatement(next)
285302

286303
return next
287304
}

0 commit comments

Comments
 (0)