From 07b6964a9b5f4b93ce4f2978b8ac74f777b1708d Mon Sep 17 00:00:00 2001 From: 0thernet <894119+0thernet@users.noreply.github.com> Date: Mon, 28 Sep 2026 06:07:09 -0400 Subject: [PATCH] Make shipped TypeScript sources erasable-syntax clean Consumers that resolve this package's "types" entries compile the shipped src/*.ts under their own compiler options. With erasableSyntaxOnly the four error classes that used constructor parameter properties failed with TS1294. Declare the fields explicitly and assign them after super() so the emitted dist keeps the same own properties and values. Enable erasableSyntaxOnly in tsconfig so the repository gate rejects regressions. --- dist/{chunk-8gyk2127.js => chunk-73r9sqrg.js} | 2 +- dist/{chunk-k2mgjyx4.js => chunk-e5csbmsf.js} | 2 +- dist/control-socket.js | 2 +- dist/custody-rust.js | 12 +++---- dist/index.js | 4 +-- dist/protected-input.js | 2 +- src/control-socket.ts | 4 ++- src/custody-rust.ts | 32 ++++++++++++++----- src/protected-input.ts | 4 ++- tsconfig.json | 1 + 10 files changed, 43 insertions(+), 22 deletions(-) rename dist/{chunk-8gyk2127.js => chunk-73r9sqrg.js} (100%) rename dist/{chunk-k2mgjyx4.js => chunk-e5csbmsf.js} (100%) diff --git a/dist/chunk-8gyk2127.js b/dist/chunk-73r9sqrg.js similarity index 100% rename from dist/chunk-8gyk2127.js rename to dist/chunk-73r9sqrg.js index 5060a96..6bfd9a2 100644 --- a/dist/chunk-8gyk2127.js +++ b/dist/chunk-73r9sqrg.js @@ -4,8 +4,8 @@ import { isatty } from "node:tty"; var DEFAULT_PROTECTED_INPUT_MAXIMUM_BYTES = 65536; class ProtectedInputError extends Error { - code; name = "ProtectedInputError"; + code; constructor(code, message) { super(message); this.code = code; diff --git a/dist/chunk-k2mgjyx4.js b/dist/chunk-e5csbmsf.js similarity index 100% rename from dist/chunk-k2mgjyx4.js rename to dist/chunk-e5csbmsf.js index 13b23b7..188ab4f 100644 --- a/dist/chunk-k2mgjyx4.js +++ b/dist/chunk-e5csbmsf.js @@ -9,8 +9,8 @@ import { chmod, unlink } from "node:fs/promises"; import { createServer, connect } from "node:net"; import { dirname } from "node:path"; class ControlSocketError extends Error { - code; name = "ControlSocketError"; + code; constructor(code, message, options) { super(message, options); this.code = code; diff --git a/dist/control-socket.js b/dist/control-socket.js index 66952af..8ddec15 100644 --- a/dist/control-socket.js +++ b/dist/control-socket.js @@ -4,7 +4,7 @@ import { attachControlSocket, listenControlSocket, requestControlSocket -} from "./chunk-k2mgjyx4.js"; +} from "./chunk-e5csbmsf.js"; import"./chunk-xrgz1k0h.js"; export { requestControlSocket, diff --git a/dist/custody-rust.js b/dist/custody-rust.js index 7d595ac..1cc4805 100644 --- a/dist/custody-rust.js +++ b/dist/custody-rust.js @@ -6,7 +6,7 @@ import { attachControlSocket, listenControlSocket, requestControlSocket -} from "./chunk-k2mgjyx4.js"; +} from "./chunk-e5csbmsf.js"; import { assertOwnedPath, ensurePrivateDirectory, @@ -16,7 +16,7 @@ import { DEFAULT_PROTECTED_INPUT_MAXIMUM_BYTES, readProtectedDescriptor, readProtectedStdin -} from "./chunk-8gyk2127.js"; +} from "./chunk-73r9sqrg.js"; import { emitLocalCustodyFallback } from "./chunk-np3mgd4s.js"; @@ -36,10 +36,10 @@ var MAXIMUM_CONTROL_TIMEOUT_MS = 3600000; var publishNamePattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,126}$/u; class CustodySidecarNotFoundError extends Error { + name; platform; arch; binaryPath; - name; constructor(platform, arch, binaryPath) { super(`local-custody sidecar not found for ${platform}-${arch} at ${binaryPath}`); this.platform = platform; @@ -50,8 +50,8 @@ class CustodySidecarNotFoundError extends Error { } class CustodySidecarTimeoutError extends Error { - timeoutMs; name; + timeoutMs; constructor(timeoutMs) { super(`local-custody sidecar did not respond within ${timeoutMs} ms`); this.timeoutMs = timeoutMs; @@ -60,9 +60,9 @@ class CustodySidecarTimeoutError extends Error { } class CustodySidecarProtocolError extends Error { + name; reason; stdout; - name; constructor(reason, stdout) { super(`local-custody sidecar produced unparseable output: ${String(reason)}`); this.reason = reason; @@ -72,9 +72,9 @@ class CustodySidecarProtocolError extends Error { } class CustodyError extends Error { + name; code; details; - name; constructor(code, details) { super(`local-custody sidecar op failed: ${code}`); this.code = code; diff --git a/dist/index.js b/dist/index.js index 1c7692f..bed9fad 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9,7 +9,7 @@ import { attachControlSocket, listenControlSocket, requestControlSocket -} from "./chunk-k2mgjyx4.js"; +} from "./chunk-e5csbmsf.js"; import { PRIVATE_DIRECTORY_MODE, PRIVATE_FILE_MODE, @@ -26,7 +26,7 @@ import { ProtectedInputError, readProtectedDescriptor, readProtectedStdin -} from "./chunk-8gyk2127.js"; +} from "./chunk-73r9sqrg.js"; // src/describe.ts var CUSTODY_ERROR_COPY = Object.freeze({ "service-not-running": Object.freeze({ diff --git a/dist/protected-input.js b/dist/protected-input.js index 0d43412..8b253b6 100644 --- a/dist/protected-input.js +++ b/dist/protected-input.js @@ -4,7 +4,7 @@ import { ProtectedInputError, readProtectedDescriptor, readProtectedStdin -} from "./chunk-8gyk2127.js"; +} from "./chunk-73r9sqrg.js"; export { readProtectedStdin, readProtectedDescriptor, diff --git a/src/control-socket.ts b/src/control-socket.ts index ecce33a..2b7fe38 100644 --- a/src/control-socket.ts +++ b/src/control-socket.ts @@ -22,8 +22,10 @@ export type ControlSocketErrorCode = /** A control request failure with a stable `code`. Messages are unchanged from earlier releases. */ export class ControlSocketError extends Error { override readonly name = "ControlSocketError"; - constructor(readonly code: ControlSocketErrorCode, message: string, options?: Readonly<{ cause?: unknown }>) { + readonly code: ControlSocketErrorCode; + constructor(code: ControlSocketErrorCode, message: string, options?: Readonly<{ cause?: unknown }>) { super(message, options); + this.code = code; } } diff --git a/src/custody-rust.ts b/src/custody-rust.ts index a57b02e..941fd0e 100644 --- a/src/custody-rust.ts +++ b/src/custody-rust.ts @@ -50,31 +50,43 @@ const publishNamePattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,126}$/u; export class CustodySidecarNotFoundError extends Error { override readonly name: "CustodySidecarNotFoundError"; + readonly platform: string; + readonly arch: string; + readonly binaryPath: string; constructor( - readonly platform: string, - readonly arch: string, - readonly binaryPath: string, + platform: string, + arch: string, + binaryPath: string, ) { super(`local-custody sidecar not found for ${platform}-${arch} at ${binaryPath}`); + this.platform = platform; + this.arch = arch; + this.binaryPath = binaryPath; this.name = "CustodySidecarNotFoundError"; } } export class CustodySidecarTimeoutError extends Error { override readonly name: "CustodySidecarTimeoutError"; - constructor(readonly timeoutMs: number) { + readonly timeoutMs: number; + constructor(timeoutMs: number) { super(`local-custody sidecar did not respond within ${timeoutMs} ms`); + this.timeoutMs = timeoutMs; this.name = "CustodySidecarTimeoutError"; } } export class CustodySidecarProtocolError extends Error { override readonly name: "CustodySidecarProtocolError"; + readonly reason: unknown; + readonly stdout: string; constructor( - readonly reason: unknown, - readonly stdout: string, + reason: unknown, + stdout: string, ) { super(`local-custody sidecar produced unparseable output: ${String(reason)}`); + this.reason = reason; + this.stdout = stdout; this.name = "CustodySidecarProtocolError"; } } @@ -85,11 +97,15 @@ export class CustodySidecarProtocolError extends Error { */ export class CustodyError extends Error { override readonly name: "CustodyError"; + readonly code: string; + readonly details: Readonly>; constructor( - readonly code: string, - readonly details: Readonly>, + code: string, + details: Readonly>, ) { super(`local-custody sidecar op failed: ${code}`); + this.code = code; + this.details = details; this.name = "CustodyError"; } } diff --git a/src/protected-input.ts b/src/protected-input.ts index f95ec38..e762803 100644 --- a/src/protected-input.ts +++ b/src/protected-input.ts @@ -8,8 +8,10 @@ export type ProtectedInputErrorCode = "protected-terminal" | "protected-unsafe-f /** A protected-input refusal with a stable `code` for `describeCustodyError`. */ export class ProtectedInputError extends Error { override readonly name = "ProtectedInputError"; - constructor(readonly code: ProtectedInputErrorCode, message: string) { + readonly code: ProtectedInputErrorCode; + constructor(code: ProtectedInputErrorCode, message: string) { super(message); + this.code = code; } } diff --git a/tsconfig.json b/tsconfig.json index 3259e95..b987955 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,7 @@ "noUnusedLocals": true, "noUnusedParameters": true, "useUnknownInCatchVariables": true, + "erasableSyntaxOnly": true, "allowImportingTsExtensions": true, "isolatedModules": true, "skipLibCheck": true,