Skip navigation
📢Introducing ArkRegex📢
0:00 / 0:32

📢Introducing ArkRegex📢

ArkType

@arktypeio6K followers

Visit on X
3,101 likesDownloadOriginal post

734,424 views

📢Introducing ArkRegex📢 a drop in replacement for new RegExp() with types ⬇️

45 Comments

Comments from the original post on X (Twitter)

  • ArkType's profile picture

    @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's profile picture

    @colinhacks

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

    149 likes

  • phong's profile picture

    @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

  • ArkType's profile picture

    @arktypeio

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

    152 likes

  • Rhys's profile picture

    @RhysSullivan

    This is insane

    33 likes

  • Maurice Kleine's profile picture

    @mauricekleine

    there's Doom in Typescript, and juuuuuust below that is ArkRegex

    28 likes

  • kenneth's profile picture

    @kennethnym

    typesafe eval() wen?

    24 likes

  • Salman Shaikh's profile picture

    @slmn_sh

    how is this even possible in typescript?

    16 likes

  • ArkType's profile picture

    @arktypeio

    unironically same strategy used to run DOOM (but highly optimized)

    177 likes

  • Salman Shaikh's profile picture

    @slmn_sh

    wait! you can run DOOM in ts?

    4 likes

  • Salman Shaikh's profile picture

    @slmn_sh

    cool!

    4 likes

  • Aman's profile picture

    @amanvarshney01

    Plz stop kidding 🙏

    14 likes

  • Ray's profile picture

    @ramonclaudio

    🔮 and thank you!

    13 likes

  • ArkType's profile picture

    @arktypeio

    readable regex for the masses✊

    12 likes

  • Maximilian's profile picture

    @_maxscn

    can I safely use this and not have my lsp blow up?

    12 likes

  • ArkType's profile picture

    @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

  • ArkType's profile picture

    @arktypeio

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

    10 likes

  • Maximilian's profile picture

    @_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

  • ArkType's profile picture

    @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

  • ArkType's profile picture

    @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