fix ControlledTransaction<infer DB, any> inferring DB as string - #1967
Open
igalklebanov wants to merge 2 commits into
Open
fix ControlledTransaction<infer DB, any> inferring DB as string#1967igalklebanov wants to merge 2 commits into
ControlledTransaction<infer DB, any> inferring DB as string#1967igalklebanov wants to merge 2 commits into
Conversation
When `S` is instantiated as `any`, `ReleaseSavepoint`'s deferred conditional in `releaseSavepoint`'s return type leaked a bogus `string` inference candidate into `infer DB`. Short-circuit `ReleaseSavepoint` to `string[]` when `S` is `any`. Side effect: `ControlledTransaction` assignable to `Transaction` dropped from 330097 to 155377 instantiations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
⏱️ TypeScript Benchmark Results |
Covers `savepoint`/`rollbackToSavepoint`/`releaseSavepoint` savepoint-list typing, invalid-name rejection, the `S = any` degradation of `releaseSavepoint` to `string[]`, and `infer` patterns over `ControlledTransaction`/`Transaction`. The `S = any` and `infer DB` assertions fail without the `ReleaseSavepoint` guard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an inference regression introduced by the
Transaction/ControlledTransactionintersection rewrite in this branch, and removes the branch's one remaining perf regression while at it.Problem:
T extends ControlledTransaction<infer DB, any> ? DB : neversilently infersDBasstringinstead of the actual database type. The bogus candidate leaks out ofreleaseSavepoint's return type: withSinstantiated asany, theReleaseSavepointutility's recursion stays a deferred conditional and poisons structural inference.RollbackToSavepointis immune because its success branch returnsSrather than the inferred tuple prefix.Fix: short-circuit
ReleaseSavepointtostring[]whenSisany(0 extends 1 & Sguard).Perf
Measured like the table in #1962:
tsc --noEmit --extendedDiagnosticsper assignability case, three runs each. "Before" is this branch's current head (808047a), "after" adds this commit. Measured with--skipLibCheckand a minimal two-table fixture, so instantiation counts isolate the assignability work itself (which is why the cheap cases show tens instead of ~12k).The guard halves the
ControlledTransactionassignable toTransactioncase because the same deferred conditional that poisoned inference was also doing work during assignability checking. Going by the numbers in #1962, that case is now faster than master's class design (260-290ms on stable TS), so the trade-off flagged there as debatable no longer exists. The ts-benchmark baseline is updated to the new count.Verified
pnpm build,pnpm test:typings, ts-benchmarks (clean, one improved baseline), plus targeted probes for<infer D, any>,<infer D, infer S>,<infer D>,<infer D, string[]>,<any, infer S>andReleaseSavepointtuple correctness, on both TypeScript 7.0.2 and 5.4 (oldest supported).🤖 Generated with Claude Code