Skip to content

Commit 85c373e

Browse files
fix: export types used in public API signatures for declaration emit compatibility (#1231)
* Export types occurring in public signatures * Changeset * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 83d5ac8 commit 85c373e

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@tanstack/db': patch
3+
---
4+
5+
fix: export types used in public API signatures for declaration emit compatibility
6+
7+
Types like `SchemaFromSource`, `MergeContextWithJoinType`, `WithResult`, `ResultTypeFromSelect`, and others
8+
are used in the public method signatures of `BaseQueryBuilder` (e.g. `from()`, `join()`, `select()`) but
9+
were not re-exported from the package's public API. This caused TypeScript error TS2742 when consumers used
10+
`declaration: true` in their tsconfig, as TypeScript could not name the inferred types in generated `.d.ts` files.
11+
12+
Fixes #1012

packages/db/src/query/builder/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,26 @@ export type QueryResult<T> = GetResult<ExtractContext<T>>
910910
// Export the types from types.ts for convenience
911911
export type {
912912
Context,
913+
ContextSchema,
913914
Source,
914915
GetResult,
915916
RefLeaf as Ref,
916917
InferResultType,
918+
// Types used in public method signatures that must be exported
919+
// for declaration emit to work (see https://github.com/TanStack/db/issues/1012)
920+
SchemaFromSource,
921+
InferCollectionType,
922+
MergeContextWithJoinType,
923+
MergeContextForJoinCallback,
924+
ApplyJoinOptionalityToMergedSchema,
925+
ResultTypeFromSelect,
926+
WithResult,
927+
JoinOnCallback,
928+
RefsForContext,
929+
WhereCallback,
930+
OrderByCallback,
931+
GroupByCallback,
932+
SelectObject,
933+
FunctionalHavingRow,
934+
Prettify,
917935
} from './types.js'

packages/db/src/query/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,28 @@ export {
77
type InitialQueryBuilder,
88
type QueryBuilder,
99
type Context,
10+
type ContextSchema,
1011
type Source,
1112
type GetResult,
1213
type InferResultType,
1314
type ExtractContext,
1415
type QueryResult,
16+
// Types needed for declaration emit (https://github.com/TanStack/db/issues/1012)
17+
type SchemaFromSource,
18+
type InferCollectionType,
19+
type MergeContextWithJoinType,
20+
type MergeContextForJoinCallback,
21+
type ApplyJoinOptionalityToMergedSchema,
22+
type ResultTypeFromSelect,
23+
type WithResult,
24+
type JoinOnCallback,
25+
type RefsForContext,
26+
type WhereCallback,
27+
type OrderByCallback,
28+
type GroupByCallback,
29+
type SelectObject,
30+
type FunctionalHavingRow,
31+
type Prettify,
1532
} from './builder/index.js'
1633

1734
// Expression functions exports

0 commit comments

Comments
 (0)