Skip to content

Some public API types are not exported from @clickhouse/client since 1.23.0 #997

Description

@Saitgalin

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions