Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the type inference performance of e.op #1021

Open
scotttrinh opened this issue May 13, 2024 · 2 comments
Open

Improve the type inference performance of e.op #1021

scotttrinh opened this issue May 13, 2024 · 2 comments

Comments

@scotttrinh
Copy link
Collaborator

As written, our current e.op implementation is O(n) on the number of separate overloads we've defined for it, which is currently in the 270ish range. That means overloads define later are more expensive. Recently, TypeScript 5.3 introduced some changes to type inference that have made this bad situation much worse. We need to find a more efficiently set of overloads for e.op that makes selecting the right overload something closer to constant (constant over the number of forms unary, binary, and ternary?) if possible.

@spalger
Copy link

spalger commented May 13, 2024

I think if you did something like e.op["="](left, right) it doesn't read quite as well but now each op is a separate function (possibly with its own docs and expamples) and you get the discoverability in autocomplete of different ops when you type e.op[".

Might also make sense to add alphanumeric shortcuts like e.op.eq/lt/gt/gte (for =. <. >, >=), then you would be able to avoid the ["..."] syntax most of the time like you could with the in op.

@scotttrinh
Copy link
Collaborator Author

@spalger

We have plans introduce a different and separate API for operators and I'll definitely link here once we get started on that. Thanks for your ideas here, we've toyed around with a similar API and similar symbol vs name concerns, so I know that will be something we address in our updated take on this.

This specific issue is to improve the existing overload API so that the mountains of existing code people have written can benefit from better type inference performance (which recently regressed a ton in TypeScript 5.3) without them having to update their code or writing a code mod, etc.

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

No branches or pull requests

2 participants