ClickHouse / ClickHouse/clickhouse-js
Some public API types are not exported from @clickhouse/client since 1.23.0
- Dominant language
- TypeScript
- Stars
- 331
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Since 1.23.0, when `@clickhouse/client-common` was bundled into the client (#845), a few types that the client's own public methods use are not re-exported from `@clickhouse/client`:
- `QueryParamsWithFormat`: the parameter of `query()`
- `PingParams`: the parameter of `ping()`
- `ResultJSONType` and `RowJSONType`: what `ResultSet.json()` and `Row.json()` return
- `ClickHouseSummary` and `WithClickHouseSummary`: fields of `InsertResult` and `CommandResult`
I could not find a supported place to import them from. `@clickhouse/client-common` is deprecated, and its npm deprecation message says to import from `@clickhouse/client` instead, but these types are not there. There is also no `exports` map in the package, so the only options left are copying the type into my own code or importing from `dist/`.
The internal things (`Connection*`, `LogWriter`, `getConnectionParams` and so on) are obviously left out on purpose, but these ones are part of the public API. Probably the same miss as #935, where `EXCEPTION_TAG_HEADER_NAME` and `extractErrorAtTheEndOfChunk` were added back in 1.23.1.
**Steps to reproduce**
1. `npm i @clickhouse/client@1.23.1 typescript`
2. Put the code below into `probe.ts`
3. `npx tsc --noEmit probe.ts --module nodenext --moduleResolution nodenext --target esnext --strict`
**Expected behaviour**
If a type is used in the signature of a public method, it should be importable from the package root. Otherwise you cannot write a wrapper with the same signature.
**Code example**
```ts
import type {
ClickHouseSummary,
PingParams,
QueryParamsWithFormat,
ResultJSONType,
RowJSONType,
WithClickHouseSummary
} from '@clickhouse/client'
```
What I needed it for: a wrapper around `query()` that adds a `query_id` to every request, so the query can be killed on abort. To keep format inference it has to take the same params as `query()`:
```ts
async function chQuery(
params: QueryParamsWithFormat // cannot be imported
) { /* ... */ }
```
Copying the type from `common/client.d.ts` as is works fine, so I don't think anything changed in the API here:
```ts
type QueryParamsWithFormat = Omit & {
format?: Format
}
```
**Error log**
```
probe.ts(2,3): error TS2305: Module '"@clickhouse/client"' has no exported member 'ClickHouseSummary'.
probe.ts(3,3): error TS2305: Module '"@clickhouse/client"' has no exported member 'PingParams'.
probe.ts(4,3): error TS2305: Module '"@clickhouse/client"' has no exported member 'QueryParamsWithFormat'.
probe.ts(5,3): error TS2305: Module '"@clickhouse/client"' has no exported member 'ResultJSONType'.
probe.ts(6,3): error TS2305: Module '"@clickhouse/client"' has no exported member 'RowJSONType'.
probe.ts(7,3): error TS2305: Module '"@clickhouse/client"' has no exported member 'WithClickHouseSummary'.
```
**Configuration**
- Client version: 1.23.1, same on `1.24.0-head.443b2f0.1` and on `@clickhouse/client-web@1.23.1`
- Node.js 26.7.0, TypeScript 7.0.2
- macOS
Contributor guide
Research direction
Start with common/client.d.ts and the @clickhouse/client package-root exports, then run the probe.ts TypeScript command from the report. Check that the six listed public types are re-exported without exposing the internal Connection* or LogWriter types. Done means the sample imports and tsc --noEmit command succeed for the supported client packages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100