Skip to content

Make TypeScript sources compatible with --erasableSyntaxOnly#768

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/transform-typescript-syntax
Draft

Make TypeScript sources compatible with --erasableSyntaxOnly#768
Copilot wants to merge 1 commit into
mainfrom
copilot/transform-typescript-syntax

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

Summary

Removes all TypeScript-only syntax extensions that emit runtime code, so the project can be built/typechecked with --erasableSyntaxOnly (and consumed by runtimes like Node's native TS stripping). The option is enabled in tsconfig.base.json to lock this in.

  • Enums → as const object + type alias. Preserves Foo.Bar member access and runtime values. Applied to the public ClickHouseLogLevel and to internal/test enums (TestEnv, TestConnectionType, local test enums in select_query_binding.test.ts).
  • Constructor parameter properties → explicit field declarations + assignments. Applied to TupleParam, SettingsMap, LogWriter, WebConnection, web/node ResultSet, NodeBaseConnection, SocketPool, and the BufferReader test helper.
  • Reverse enum lookup. The old ClickHouseLogLevel[this.logLevel] (used for the startup log message) is replaced by a derived ClickHouseLogLevelName reverse map; output is unchanged.
  • tsconfig.base.json: "erasableSyntaxOnly": true.

Example of the enum transform — call sites such as ClickHouseLogLevel.TRACE continue to work:

export const ClickHouseLogLevel = {
  TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, OFF: 127,
} as const
export type ClickHouseLogLevel =
  (typeof ClickHouseLogLevel)[keyof typeof ClickHouseLogLevel]

No namespaces or import = require(...) exist in the tree, so nothing else needed to change.

Checklist

  • A human-readable description of the changes was provided to include in CHANGELOG

CHANGELOG

  • Internal: TypeScript sources are now compatible with the --erasableSyntaxOnly compiler option. ClickHouseLogLevel is now exported as a const object plus a union type instead of a TS enum; runtime values and ClickHouseLogLevel.TRACE-style member access are unchanged.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants