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
npm i @clickhouse/client@1.23.1 typescript
- Put the code below into
probe.ts
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
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():
async function chQuery<Format extends DataFormat = 'JSON'>(
params: QueryParamsWithFormat<Format> // 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:
type QueryParamsWithFormat<Format extends DataFormat> = Omit<QueryParams, 'format'> & {
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
Describe the bug
Since 1.23.0, when
@clickhouse/client-commonwas 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 ofquery()PingParams: the parameter ofping()ResultJSONTypeandRowJSONType: whatResultSet.json()andRow.json()returnClickHouseSummaryandWithClickHouseSummary: fields ofInsertResultandCommandResultI could not find a supported place to import them from.
@clickhouse/client-commonis deprecated, and its npm deprecation message says to import from@clickhouse/clientinstead, but these types are not there. There is also noexportsmap in the package, so the only options left are copying the type into my own code or importing fromdist/.The internal things (
Connection*,LogWriter,getConnectionParamsand so on) are obviously left out on purpose, but these ones are part of the public API. Probably the same miss as #935, whereEXCEPTION_TAG_HEADER_NAMEandextractErrorAtTheEndOfChunkwere added back in 1.23.1.Steps to reproduce
npm i @clickhouse/client@1.23.1 typescriptprobe.tsnpx tsc --noEmit probe.ts --module nodenext --moduleResolution nodenext --target esnext --strictExpected 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
What I needed it for: a wrapper around
query()that adds aquery_idto every request, so the query can be killed on abort. To keep format inference it has to take the same params asquery():Copying the type from
common/client.d.tsas is works fine, so I don't think anything changed in the API here:Error log
Configuration
1.24.0-head.443b2f0.1and on@clickhouse/client-web@1.23.1