speed up assigning Transaction to a Kysely - #1962
Open
koskimas wants to merge 2 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
⏱️ TypeScript Benchmark Results |
It's a very common thing to have a function that takes a Kysely as an argument and then to pass in a Transaction instance. Before this commit it was extremely slow. Like hundreds of thousands of type instantations slow, even for a trivial database.
koskimas
force-pushed
the
speed-up-transaction-type-checks
branch
from
July 31, 2026 04:35
2dcf72e to
36622b0
Compare
This was referenced Aug 1, 2026
igalklebanov
reviewed
Aug 3, 2026
| * This is an intersection of {@link TransactionMethods} and {@link Kysely} | ||
| * rather than a subclass of `Kysely` for type check performance reasons. | ||
| * | ||
| * `Transaction` is still a class at runtime, so `db instanceof Transaction` |
Member
There was a problem hiding this comment.
we should not encourage instanceof.
igalklebanov
reviewed
Aug 3, 2026
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.
It's a very common thing to have a function that takes a Kysely as an argument and then to pass in a Transaction instance.
Before this commit it was extremely slow. Like hundreds of thousands of type instantations slow, even for a trivial database.
This change is debatable. It doesn't actually remove the infinite recursion (TS7 still produces more instantations) and it makes assigning
ControlledTransactiontoTransactionslower.I'm fine with not merging this. Let's first see if it's possible to get rid of the recursion alltogether.