You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would allow a set of scopes/types to be precompiled to avoid JIT compilation at runtime.
This requires additional investigation around possible targets (ts vs js build output) and tooling (TS-morph vs some JS AST transformer or other).
Reacted by Spence, Nithin, Alexander Carls, Marc Agbanchenou, Roberto Wesley Overdijk, Magnar Ovedal Myrtveit, Matthew Bell, Guillaume Humbert, Ryan Atkinson, lin72h and 19 more
Very interesting. Would this be something similar to what Typia does? Though I don't think Typia can handle anything that cannot be expressed as TypeScript types.
Not exactly. ArkType already uses these kind of JIT optimizations internally so it's really just a matter of outputting them as part of a build process, figuring out constraints around how + where types can be defined, non-serializable constraints etc.
Reacted by Magnar Ovedal Myrtveit, lin72h, dh0012, Parsa Shamaeezadeh, Roman and Zhihan WU
This would be great to see. After evaluating ArkType in the realm of browser extensions, the startup performance penalty is a non-starter for us. We use validation heavily (specifically matching with allows in ArkType), to route messages between content scripts and the background service. Extensions communication is done via JSON serialization so we don't retain types between them. We have some fairly ridiculous kind of type unions (470+ possible different strings), nested in even larger objects, which is probably a big reason it's so slow.
Startup performance is critical though, because content scripts run on every page if the user is running the extension. Here's a performance grab from loading the ArkType docs with our extension enabled. About 14 seconds of a frozen tab with 100% CPU usage.
We would much rather take the hit in the build step (which pretty much every serious project will have anyway), rather than passing it on to our users, on every page they visit.
To be a bit more positive, I think it's a really cool system, and the DX is pretty good!
Hi, I've been following the discussion on precompilation.
Have you considered an approach similar to Bun Macros? It allows functions to run at bundle-time and inline the returned value directly into the source. This seems to align perfectly with the goal of zero-runtime overhead for complex schemas.
I realize this approach requires the return value to be JSON-serializable and leads to vendor lock-in, but I thought it might be worth mentioning as a reference.
Hi, I've been experimenting with AOT optimization for ArkType using Bun Macros.
I created a PoC that pre-compiles schemas at build time, and the performance improvement looks significant.
Activity
Stadly commentedon Mar 11, 2025
Very interesting. Would this be something similar to what Typia does? Though I don't think Typia can handle anything that cannot be expressed as TypeScript types.
ssalbdivad commentedon Mar 11, 2025
Not exactly. ArkType already uses these kind of JIT optimizations internally so it's really just a matter of outputting them as part of a build process, figuring out constraints around how + where types can be defined, non-serializable constraints etc.
flagpoonage commentedon Oct 8, 2025
This would be great to see. After evaluating ArkType in the realm of browser extensions, the startup performance penalty is a non-starter for us. We use validation heavily (specifically matching with
allowsin ArkType), to route messages between content scripts and the background service. Extensions communication is done via JSON serialization so we don't retain types between them. We have some fairly ridiculous kind of type unions (470+ possible different strings), nested in even larger objects, which is probably a big reason it's so slow.Startup performance is critical though, because content scripts run on every page if the user is running the extension. Here's a performance grab from loading the ArkType docs with our extension enabled. About 14 seconds of a frozen tab with 100% CPU usage.
We would much rather take the hit in the build step (which pretty much every serious project will have anyway), rather than passing it on to our users, on every page they visit.
To be a bit more positive, I think it's a really cool system, and the DX is pretty good!
miyaji255 commentedon Nov 27, 2025
Hi, I've been following the discussion on precompilation.
Have you considered an approach similar to Bun Macros? It allows functions to run at bundle-time and inline the returned value directly into the source. This seems to align perfectly with the goal of zero-runtime overhead for complex schemas.
I realize this approach requires the return value to be JSON-serializable and leads to vendor lock-in, but I thought it might be worth mentioning as a reference.
miyaji255 commentedon Dec 6, 2025
Hi, I've been experimenting with AOT optimization for ArkType using Bun Macros.
I created a PoC that pre-compiles schemas at build time, and the performance improvement looks significant.
Here is the repository and the benchmark results:
https://github.com/miyaji255/arktype-macro-bench
docs: cite fixed issues and record two missed changes in the package …
docs(type): cite the issues the release fixes and add the entries it …
ssalbdivad commentedon Nov 18, 2026
Fixed in 3.0.0-beta.0 (#1728). Try it with
npm i arktype@next.