Repository navigation
perf(client, tanstack-query, swr, pinia-colada, effect, openapi): drop redundant per-key client checks in recursive types - #2467
Conversation
…p redundant per-key client checks in recursive types Recursive client-mapping types re-checked `T[K] extends AnyNestedClient` for every key, repeating a structural Client/NestedClient check that the outer `T extends AnyNestedClient` constraint already guarantees. Move the recursion into an unconstrained `*Impl<T>` helper that recurses directly. Optional procedures now map to `X | undefined` instead of collapsing to `undefined`, and `JsonifiedClient` now jsonifies optional procedures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7SZS3Fak2JESZSqnFm
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
orpc | 7fbd9f5 | Commit Preview URL Branch Preview URL |
Nov 15 2026, 08:38 AM |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/mcp
@orpc/msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
ℹ️ Minor suggestions only.
Reviewed changes
- Client inference aliases (
packages/client/src/types.ts) — the sixInferClient*aliases now forward to unconstrained*Implhelpers, andInferClientErrorgained-?so optional procedures no longer leakundefinedinto the flattened error union. SafeClientandORPCClientScoped— same alias/helper split, so optional procedures stay typed asSafeResult<…> | undefined/ORPCClientScopedOptions<…> | undefinedinstead of collapsing tonever.EffectClient(packages/effect) — split intoEffectClientImpl, same as the client package.RouterUtils/RouterUtilsScoped(tanstack-query,pinia-colada,swr) — per-key client checks removed; the& Public<SharedUtils<unknown>>intersection and the?/| undefinedscoped shape are unchanged.JsonifiedClient(packages/openapi) — recurses throughJsonifiedClientImpland drops the old: T[K]non-client passthrough, so optional procedures now get their outputs JSON-ified.- Type tests — optional-procedure cases added across
client,client-safe,effect,openapi,pinia-colada,swrandtanstack-query.
Checked the claims rather than taking them on trust: AnyNestedClient's object branch requires every property to be NestedClient<any>, and a required property typed Client | undefined fails that constraint, so the removed per-key guards (and JsonifiedClient's passthrough) are genuinely unreachable from conforming inputs. Ad-hoc probes against this head confirm the new results, including InferClientError<{ ping?: Client<{}, string, number, Error> }> = Error with no undefined or {} leakage, and tsc -p tsconfig.json --noEmit (which pulls in every *.test-d.ts) passes.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
… public alias names in generic declaration emit Aliasing the public types directly to the unexported `*Impl` helpers made generic signatures (e.g. a user's `<T extends AnyNestedClient>(c: T) => createSafeClient(c)`) emit an inlined, depth-limited type ending in `/*elided*/ any` instead of `SafeClient<T>`. Wrap the helper in a deferred `T extends unknown` conditional so the public alias is what gets named, matching the previous output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7SZS3Fak2JESZSqnFm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7SZS3Fak2JESZSqnFm
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the emit fix holds up. One coverage gap worth a look below.
Reviewed changes
Reviewed the follow-up commit that defers every public recursive client type through a conditional wrapper so consumer declaration emit keeps the public alias name.
- Deferred conditional on all 15 public aliases —
SafeClient,ORPCClientScoped, the sixInferClient*aliases,EffectClient,JsonifiedClient, andRouterUtils/RouterUtilsScopedintanstack-query,pinia-coladaandswrnow forward asT extends unknown ? XImpl<T> : neverrather than a bare= XImpl<T>. - Rationale comment above each
*Implhelper — the same three-line note explains the removed per-keyAnyNestedClientcheck and why the public alias defers, repeated at every site. - No test changes —
*.test-d.tsfiles are untouched by this commit.
I reproduced both sides of the emit claim against the repo's TS 7.0.2: with the bare forward, a generic consumer wrapper (<T extends AnyNestedClient>(c: T) => createSafeClient(c)) emits a fully inlined mapped type truncated to /*elided*/ any at depth 10; with the wrapper it emits SafeClient<T>, including inside Promise<> and object-property positions. The wrapper is semantically neutral here because every *Impl is already a distributive conditional on naked T, so the extra layer distributes over unions of the client type identically. tsc -p tsconfig.json --noEmit is clean at ba07a46.
ℹ️ The declaration-emit guard is invisible to CI
T extends unknown is load-bearing only for consumer .d.ts, which no repo check exercises. pnpm check runs oxlint with typeCheck: true (no emit), vitest only collects *.test.ts, and the package build emits @orpc/client's own .d.ts, which is valid in the bare form as well — 69af539 shipped exactly that and stayed green. So the wrapper reads exactly like the redundancy this PR exists to delete, and the comment is currently the only thing protecting it.
Technical details
# Declaration-emit regression is unguarded
## Affected sites
- `packages/client/src/client-safe.ts:8` — `SafeClient` wrapper (the pattern is repeated in all 15 aliases)
- `packages/client/src/types.ts:53-166` — the six `InferClient*` aliases
- `packages/client/src/client.ts:46`, `packages/effect/src/client.ts:22`, `packages/openapi/src/types.ts:78`
- `packages/tanstack-query/src/router-utils.ts:30,42`, `packages/pinia-colada/src/router-utils.ts:30,42`, `packages/swr/src/router-utils.ts:10`
## Required outcome
- A future edit that reduces any public alias back to `= XImpl<T>` fails a check instead of silently truncating consumer declaration emit to `/*elided*/ any`.
## Suggested approach (optional)
- A single fixture test: write a temp consumer module that imports `@orpc/client` (and one integration) and declares a generic wrapper around `createSafeClient` / `createRouterUtils`, compile it with `--declaration --emitDeclarationOnly` via `execSync` using the pinned `typescript`, and assert the emitted `.d.ts` names the public alias and contains no `elided` / `Impl`. One case covers all aliases because the mechanism is shared.
- Cheaper alternative: leave the code as-is and record the constraint where contributors look (e.g. a line in `AGENTS.md` under the type-test section), so the invariant is discoverable outside the file-local comments.
## Open questions for the human
- Is an emit fixture test in scope for this PR, or should the invariant only be documented?deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the follow-up commit that adds the last missing type-test case from the earlier review.
ORPCClientScopedoptional-procedure coverage — a new top-level case inpackages/client/src/client.test-d.tsassertsScoped['ping']isORPCClientScopedOptions<{ cache: string }, number, string, Error> | undefinedand that the nested optionalpongkeepsORPCClientScopedOptions<…> | undefined.- Regression value confirmed — the test targets the exact behavior this PR changes: the old non-distributive per-key
T[K] extends AnyNestedClientcheck collapsed both properties toundefined, so the assertions fail against the pre-PR types and pass now. - No production code touched — the commit is type-test only;
tsc -p tsconfig.json --noEmitandoxlint packages/client/src/client.test-d.tsare clean at3773234.
The earlier ORPCClientScoped thread is addressed by this commit and has been resolved.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
… export recursive helpers as `*Internal` Replace the `T extends unknown` wrapper with exported `*Internal` helpers (e.g. `SafeClientInternal`) that the public aliases point at directly. Being exported, a consumer's declaration emit can always name them, so generic wrappers no longer inline a truncated type. Add a declaration-emit test that compiles a consumer with generic wrappers for every recursive client type and fails if any is inlined or unnameable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7SZS3Fak2JESZSqnFm
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the commit that replaces the elided-emit workaround with exported *Internal helpers and adds a declaration-emit regression test.
- Exported
*Internalcounterparts for all 15 recursive client types — public aliases now forward straight through (export type X<T extends AnyNestedClient> = XInternal<T>), and theT extends unknown ? XImpl<T> : neverdeferral plus its repeated three-line comment are gone. - New declaration-emit test (
tests/types/declaration-emit.test.ts) — compiles a virtual consumer module through the repo'stypescript-6API, one generic wrapper per public alias, and asserts the emitted.d.tsis diagnostic-free, names<alias>Internal<T>, and never containselided. - CI coverage for the invariant — the file is collected by the root vitest project (
**/*.test.ts), so thetest:coveragejob exercises it on every Node version in the matrix, closing the "emit guard is invisible to CI" gap raised on theba07a46review.
Verified rather than assumed: un-exporting EffectClientInternal fails both the elided assertion and the effect EffectClient naming assertion, so the guard has teeth; a probe that returns these types in nested positions (Promise<...>, object properties, array elements) emits ...Internal<T> everywhere without inlining, so dropping the deferral does not reintroduce elision; the new test (17 assertions, ~2s), tsc -p tsconfig.json --noEmit and oxlint on every touched file are clean at 7fbd9f5.
Emit now names the internal helper rather than the public alias (SafeClientInternal<T> instead of SafeClient<T>). That is the tradeoff documented in the PR body, and also the more robust side of it: an exported, nameable helper does not rely on the printer remembering a deferral.
Resolve conflicts with #2467 (unconstrained `*Internal` infer types): keep its structure, add `InferClientContextInternal` for the leaf walk, and keep both sides' appended type tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7SLD43iJSE4suogZAd
…hecks in recursive types (#2477) ## What This applies the refactor from #2467 to the server-side and contract router types. They used this shape: ```ts { [K in keyof T]: T[K] extends RouterContract ? X<T[K]> : never } // server types also had a fallback: T[K] extends Lazyable<infer U extends AnyRouter> ? X<U> : never ``` The outer `T extends RouterContract` / `T extends AnyRouter` constraint already guarantees what the per-key check tests. The recursion now runs through an exported, unconstrained `*Internal` helper, and the public alias keeps the constraint: ```ts export type X<T extends RouterContract> = XInternal<T> export type XInternal<T> = T extends <leaf> ? ... : { [K in keyof T]: XInternal<T[K] & {}> } ``` For server types, the lazy unwrapping moves into the helper as a `T extends Lazy<infer U>` branch. It only runs on non-procedure nodes. Because `T` is distributive there, `Lazyable<...>` keys still work. Types changed (each gains an exported `*Internal` helper): - `contract`: `InferRouterContractInputs`, `InferRouterContractOutputs`, `InferRouterContractErrorMap`, `InferRouterContractError`, `InferRouterContractErrors`, `AugmentedContractRouter` - `server`: `ContractedRouter`, `InferRouterInitialContexts`, `InferRouterFinalContexts`, `InferRouterInputs`, `InferRouterOutputs`, `InferRouterErrors`, `InferRouterError`, `UnlaziedRouter`, `AugmentedRouter`, `AugmentedRouterWithMiddlewares`, `RouterClient` - `openapi`: `PopulatedContractRouterOpenAPIPaths` - `msw`: `HTTPRouterUtils` ### Why `T[K] & {}` instead of plain `T[K]` With a bare `XInternal<T[K]>`, TS keeps inferring `T` back through the mapped type when the call's contextual type is recursive. Each level creates a fresh reverse-mapped type, and the comparison against the constraint never ends. This happened inside the repo's own code and tests: ```ts // TS2321: Excessive stack depth comparing types '{ [x: string]: ...; }' and 'AnyRouter' const client: AnyNestedClient = createRouterClient(router, { context: { db } }) ``` It also showed up as an excessive-stack-depth error while TS measured variance for `SharedRouterImplementerWithMiddlewares`, through `InferRouterContractErrorMap`. A probe found the same failure in every shape-preserving type here. The trigger is a generic function returning the type, assigned to a recursive type, called with an object-literal argument typed by `T`. `main` has no such error. `T[K] & {}` stops the inference and is nearly free. Things I tried that did not work: - `NoInfer<T[K]>` keeps a wrapper around concrete object types. That turns off distribution, which breaks `Lazyable` and optional keys. - `T[K] extends infer U ? XInternal<U> : never` and `T[K] extends object ? ...` guards cost as much as the check they replace. `& {}` also drops `undefined` from optional keys, which gives the behavior described below. ### Other details - **`any` handling.** `RouterClient`, `AugmentedRouter` and `AugmentedRouterWithMiddlewares` map the first level in the public alias itself. Otherwise `any` would reach the helper's `Lazy` branch: `AugmentedRouter<any>` would gain a `Lazy<{}>` member, and `os.router({} as any)` would stop being assignable to `AnyRouter`. - **Declaration emit.** The helpers are exported so declaration emit can name them. A generic wrapper around `oc.router`, `unlazyRouter`, `populateRouterContractOpenAPIPaths` or `createHTTPUtils` now emits `AugmentedContractRouterInternal<T, ...>`, `UnlaziedRouterInternal<T>` and so on, where `main` emitted the public name. Before they were exported, TS inlined the helper's body there instead. A declaration-emit probe covering all 20 types shows these four renames and no other differences from `main`, with no inlining and no `elided`. ## Benchmark TS 7.0.2, `tsc --extendedDiagnostics --checkers 1`, on a synthetic project: a contract and a router of 60 routers × 50 procedures (3,000 procedures). Each workload accesses all 3,000 leaves, or resolves the full union for the union types. The numbers below are instantiations above a base project that only defines the router. The base itself changes by under 0.01%. The counts are deterministic. | Type | Before | After | Δ | | :-- | --: | --: | --: | | `InferRouterContractInputs` / `Outputs` | 214,276 | 205,037 | −9,239 (−4.3%) | | `InferRouterContractErrors` / `Error` | 205,276 / 205,459 | 196,037 / 196,220 | −9,239 (−4.5%) | | `InferRouterContractErrorMap` | 136,459 | 127,220 | −9,239 (−6.8%) | | `AugmentedContractRouter` (`oc.router`) | 196,566 | 187,326 | −9,240 (−4.7%) | | `PopulatedContractRouterOpenAPIPaths` | 218,564 | 209,340 | −9,224 (−4.2%) | | `HTTPRouterUtils` | 212,555 | 203,334 | −9,221 (−4.3%) | | `ContractedRouter` (`implement(contract).router(router)`) | 301,745 | 289,449 | −12,296 (−4.1%) | | `InferRouterInputs` / `Outputs` | 211,150 | 202,218 | −8,932 (−4.2%) | | `InferRouterInitialContexts` / `FinalContexts` | 184,150 / 199,150 | 175,218 / 190,218 | −8,932 (−4.9% / −4.5%) | | `InferRouterErrors` / `Error` | 241,150 / 241,333 | 232,218 / 232,401 | −8,932 (−3.7%) | | `UnlaziedRouter` | 133,028 | 124,094 | −8,934 (−6.7%) | | `RouterClient` | 238,150 | 229,270 | −8,880 (−3.7%) | | `AugmentedRouter` / `WithMiddlewares` (`os.router`) | 244,204 / 245,161 | 235,324 / 236,401 | −8,880 / −8,760 (−3.6%) | With all 60 routers wrapped in `os.lazy`, the server types save about 15k (−3.4% to −4.8%) and `ContractedRouter` saves 18k (−4.0%). The saving is about 3 instantiations per procedure. That is much smaller than the −22% on #2467. Here the removed check is a cheap comparison: #2452 to #2454 already made these types match procedures through `~orpc` and test `AnyRouter` before inferring. Most of the remaining cost is in the leaf branches. ## Behavior change (bug fixes) - **Optional keys** used to collapse to `undefined`. `X | undefined` failed the per-key check, so the key became `never`, and the optional modifier then turned it into `undefined`. They now map to their value. For example, `InferRouterInputs<{ ping?: P }>` was `{ ping?: undefined }` and is now `{ ping?: Input | undefined }`. The same applies to `RouterClient`, `ContractedRouter` and the other shape-preserving types. The existing `RouterClient` test that pinned the old result (`maps an optional key to never`) now asserts the mapped client. - **Union types** (`InferRouterError`, `InferRouterContractError`, `InferRouterContractErrorMap`) use `-?`. For a router with optional keys they were `undefined`; they now give the real union, with no `undefined`. - **`AugmentedRouter` / `AugmentedRouterWithMiddlewares`** mapped `Lazyable<...>` keys (a router or its lazy form) to `never`. `AugmentedRouter<AnyRouter>` was `{ [k: string]: never }`. Both now map properly. I compared old and new on procedures, nested, lazy, `Lazyable`, optional and readonly keys, `os.router()` output, `AnyRouter`, `RouterContract`, `any` and `never`. Apart from the cases above, the only difference is for keys typed `any` in the server types, which pick up an extra `{}` / `Lazy<{}>` union member. ## Tests New test-d cases cover optional keys for every changed type. New `AugmentedRouter*` cases cover `Lazyable` keys and assignability to `AnyRouter` for `any` / `AnyRouter`. There is a new `openapi/src/router-utils.test-d.ts`. All the new optional-key and `Lazyable` assertions fail on the old types (19 errors) and pass on the new ones. A regression test, `const c: AnyNestedClient = createRouterClient(router, { context })`, guards the overflow above. It passes on `main` and fails if `& {}` is removed. ## Verification - `pnpm check` and `pnpm docs:validate`: pass. - `tsc -p tsconfig.json` (includes all `*.test-d.ts`): pass. - `pnpm test`: 4,630 tests passed, plus `packages/bun` (100) and `packages/cloudflare` (83). That full run was before the `*Internal` rename. After the rename I re-ran the `server`, `contract`, `openapi` and `msw` tests (1,411 passed) plus the root type check. - The first full run had two failures in `packages/bun` (`cancel and abort: compression-bun-fetch`). These runtime timing tests can't be affected by a type-only change. They passed in three separate re-runs and in two later full runs. - `pnpm format` was run. It also reformatted `apps/content/sponsors/*`, which I left out of this PR. ## Note on #2467 The same probe, run against that branch's client types, fails for `InferClientInputs`, `InferClientOutputs`, `InferClientErrors`, `SafeClient`, `RouterUtils`, `EffectClient` and `JsonifiedClient` with `TS2321` (`main` passes). The probe is a generic `<T extends AnyNestedClient>(c: T, o: { ctx?: InferClientContext<T> }) => X<T>`, assigned to a recursive type and called with `{ ctx: {} }`. `T[K] & {}` would likely fix it there too.
… reverse inference through recursive client types (#2478) ## Problem #2467 rewrote the recursive client types as `T extends Client<...> ? ... : { [K in keyof T]: XInternal<T[K]> }`. The `XInternal<T[K]>` inside the mapped type isn't guarded. When a call's contextual type is recursive, TS keeps inferring `T` back through that homomorphic mapped type. Each level creates a new reverse-mapped type, and the check against the `AnyNestedClient` constraint fails: ``` TS2321: Excessive stack depth comparing types '{ [x: string]: ...; }' and 'AnyNestedClient'. ``` Minimal trigger: ```ts type Recursive = { [k: string]: Recursive } | object type Options<T extends AnyNestedClient> = { context?: InferClientContext<T> } declare function fn<T extends AnyNestedClient>(client: T, options: Options<T>): InferClientInputs<T> const _: Recursive = fn(client, { context: {} }) // TS2321 on main ``` ## Fix Recurse through `XInternal<T[K] & {}>` instead, the same approach #2477 takes for the contract and server router types. `& {}` stops the reverse inference. The helpers still distribute over unions, and optional keys still map to `?: ... | undefined` through the homomorphic mapping. Changed helpers: - `@orpc/client`: `InferClientInputs`, `InferClientBodyInputs`, `InferClientOutputs`, `InferClientBodyOutputs`, `InferClientErrors`, `InferClientError`, `SafeClient`, `ORPCClientScoped` - `@orpc/tanstack-query`, `@orpc/pinia-colada`: `RouterUtils`, `RouterUtilsScoped` - `@orpc/swr`: `RouterUtils` - `@orpc/effect`: `EffectClient` - `@orpc/openapi`: `JsonifiedClient` `InferClientError` never hit the error, because its result is an indexed union rather than a mapped object. It's changed anyway to stay consistent with the others. ### `JsonifiedClient` and non-client values `& {}` changes the result for three kinds of leaf: an explicit `null` or `undefined` leaf becomes `never`, and an `unknown` leaf becomes `{}`. Other leaves (primitives, literals, `Date`, arrays, tuples, functions, `any`, `never`, unions with clients, optional keys) give the same result as before. None of the changed leaves pass the `AnyNestedClient` constraint. `{ a: C, b: null }`, `{ a: C, b: undefined }`, `{ a: C, b: unknown }` and `{ a: C | undefined }` are all rejected, so no public type's result changes. `undefined` only gets in through optional keys, and those still come out as `?: ... | undefined`. ## Tests Each changed type gets a "with a recursive contextual type" case. In the test files this PR touches, every tested type now has one `describe` holding all of its cases: plain procedures, optional procedures, and the recursive contextual type. That covers each `InferClient*` helper, `SafeClient`, `ORPCClientScoped`, `RouterUtils`, `RouterUtilsScoped`, `createRouterUtils`, `EffectClient` and `JsonifiedClient`. Cases that used to cover `RouterUtils` and `RouterUtilsScoped` together are split between the two groups. No assertions were added or dropped while moving tests. Each type gets its own generic function, which takes an object-literal argument typed by `T` and is assigned to a recursive type. They aren't combined into one tuple or object return, because that hid a regression in a single helper. I removed the `& {}` from one helper at a time. For each of the 14 helpers that had the bug, that made its own case fail with TS2321; `InferClientError` passes either way. The optional-procedure cases from #2467 still pass. - `pnpm check` passes - `pnpm test` passes (302 files, 4647 tests)

What
Recursive client-mapping types used this shape:
The outer
T extends AnyNestedClientconstraint already guarantees every property is a client or a nested router, so the per-keyT[K] extends AnyNestedClientcheck was a second structuralClient/NestedClientcomparison on every key. The recursion now lives in an exported, unconstrained*Internaltype. The public alias keeps the constraint:The
*Internaltypes are exported so a consumer's declaration emit can always name them. Take a generic wrapper such as<T extends AnyNestedClient>(c: T) => createSafeClient(c). Its emitted return type refers toSafeClientInternal<T>. If that helper were not exported, TS could not name it from another package, so it would inline the whole type and truncate it to/*elided*/ anyat depth 10.Types changed (each gets an exported
*Internalcounterpart):client:InferClientInputs,InferClientBodyInputs,InferClientOutputs,InferClientBodyOutputs,InferClientErrors,InferClientError,SafeClient,ORPCClientScopedtanstack-query,pinia-colada:RouterUtils,RouterUtilsScopedswr:RouterUtilseffect:EffectClientopenapi:JsonifiedClientBenchmark
TS 7.0.2,
--checkers 1,RouterClientof 60 routers × 50 procedures (3,000Procedures), run onmain@ 1df6f2b. Values are instantiation counts.InferClientInputs/InferClientOutputsInferClientErrorcreateSafeClient(c)createEffectClient(c)utils.rX.pY.queryOptions(...)calls (whole program)utils.r1.p1.queryOptions(...)access"Full evaluation" means assigning the mapped result to
Record<string, Record<string, unknown>>, which forces every property to be resolved. A single property access gains little: most of its cost is checking the outerT extends AnyNestedClientconstraint once per call, and this PR leaves that check alone.Behavior change (bug fix)
Optional procedures used to collapse to
undefined.Client | undefineddoes not extendAnyNestedClient, so the property becamenever, and the optional modifier then turned it intoundefined. They now map toX | undefined. For example,InferClientInputs<{ ping?: Client<{}, string, …> }>was{ ping?: undefined }and is now{ ping?: string | undefined }.JsonifiedClientpassed optional procedures through unconverted, soDatewas not turned intostring. It now converts them.InferClientErroruses-?, so optional procedures add their error type and noundefined.Tests
tests/types/declaration-emit.test.tscompiles a consumer module with the repo'stypescript-6API. For each of the 15 public types, the consumer has a generic wrapper whose return type must be inferred. The test asserts the emit has no diagnostics, contains noelided, and names the exported*Internaltype. Un-exporting a helper fails the test.Verification
pnpm format,pnpm check,pnpm docs:validate: passtsc -p tsconfig.json(includes all*.test-d.ts): passpnpm test: 302 files and 4,647 tests passed🤖 Generated with Claude Code
https://claude.ai/code/session_01VVaw7SZS3Fak2JESZSqnFm