diff --git a/.changeset/fix-table-core-dts-module-scope.md b/.changeset/fix-table-core-dts-module-scope.md new file mode 100644 index 0000000000..780a2ad155 --- /dev/null +++ b/.changeset/fix-table-core-dts-module-scope.md @@ -0,0 +1,5 @@ +--- +'@tanstack/table-core': patch +--- + +fix(table-core): export RangeValue and ensure emitted declaration files preserve module scope diff --git a/packages/table-core/src/features/row-aggregation/aggregationFns.ts b/packages/table-core/src/features/row-aggregation/aggregationFns.ts index 22fa2e716f..ed2ab355ef 100755 --- a/packages/table-core/src/features/row-aggregation/aggregationFns.ts +++ b/packages/table-core/src/features/row-aggregation/aggregationFns.ts @@ -1,6 +1,6 @@ import { constructAggregationFn } from './rowAggregationFeature.types' -type RangeValue = Date | number +export type RangeValue = Date | number function isNumber(value: unknown): value is number { return typeof value === 'number' diff --git a/scripts/rewrite-table-core-dts.mjs b/scripts/rewrite-table-core-dts.mjs index 1d8846d39b..1ee8f41a1e 100644 --- a/scripts/rewrite-table-core-dts.mjs +++ b/scripts/rewrite-table-core-dts.mjs @@ -282,10 +282,22 @@ function rewriteDeclaration(source, file) { next = next.replaceAll('Column_Internal', 'Column') next = ensurePublicTypeImports(next, file) + next = ensureModuleScope(next) return next } +function ensureModuleScope(source) { + if ( + !/\bexport\s*(?:\{|\*|default|type|interface|function|class|const|let|var|enum)\b/.test( + source, + ) + ) { + return `${source.trimEnd()}\n\nexport {};\n` + } + return source +} + const files = walkDeclarationFiles(distDir) for (const file of files) {