📢Introducing ArkRegex📢
@arktypeio6K followers
734,424 views
45 Comments
Comments from the original post on X (Twitter)

@arktypeio
arkregex is a standalone, type-only package that adds types to RegExp. if you prefer... 🔎 clarity over opacity 🔒 safety over crashing using it should be the easiest win of your life. announcement:
183 likes

@colinhacks
david if you keep going down this path I won't be able to help you
149 likes

@PhongGT
we devs were so preoccupied with whether we could, that we didn't stop to think if we should this is amazing though
92 likes

@arktypeio
we thought about it and concluded that if you haven't already installed arkregex your project is garbage
152 likes

@RhysSullivan
This is insane
33 likes

@mauricekleine
there's Doom in Typescript, and juuuuuust below that is ArkRegex
28 likes

@kennethnym
typesafe eval() wen?
24 likes

@slmn_sh
how is this even possible in typescript?
16 likes

@arktypeio
unironically same strategy used to run DOOM (but highly optimized)
177 likes

@slmn_sh
wait! you can run DOOM in ts?
4 likes

@slmn_sh
cool!
4 likes

@amanvarshney01
Plz stop kidding 🙏
14 likes

@ramonclaudio
🔮 and thank you!
13 likes

@arktypeio
readable regex for the masses✊
12 likes

@_maxscn
can I safely use this and not have my lsp blow up?
12 likes

@arktypeio
Generally, yes. A lot of effort went into optimizing the parser including dozens of type-level benchmarks. Of course eventually you'll hit the limits of TypeScript eventually with enough unions but it's pretty easy to just not use it for those extreme cases.
63 likes

@arktypeio
There's a fallback for declaring the type or you can just use `new RegExp()` for those cases.
10 likes

@_maxscn
just for reference how many instantiations would a regular type be or a zod object - and at what number does the lsp start falling apart? I understand that these numbers are probably sensible for you (and I understand lower = better) but it’s like a currency I never used very grateful if you feel like you have the energy to explain but totally understandable if not Library is pure magic no matter what but lsp performance has burnt me completely
1 like

@arktypeio
Most of these cases are less expensive than a simple zod schema. 1-10k instantiations is pretty standard for that sort of thing.
4 likes

@arktypeio
You just have to be careful if your expression is combinatorial, but there's a ceiling on what TS will do before complaining anyways. A good heuristic would be to look at the number of branches in the union of the result type. If you see >10k, you may want to declare the type
1 like





















