David Blass @ssalbdivad.dev 路 Dec 20

In case people were curious how to write an efficient type-level string parser like @arktype.io's, I implemented today's #AdventOfTypescript using the same approach: www.adventofts.com/events/2024/...

10 likes 3 replies

?

Replies

Andrea Simone Costa 路 Dec 20

curiosity: what is the longest lookahead you are currently using in arktype?

Josh Goldberg 路 Dec 20

馃槃 I like it!!

David Blass 路 Dec 20

For a simple case like this, you could do `s extends ${string}(${infer arg})`, but shift-reduce parsing is... - More precise: allows stuff like parenthetical expressions that can't be parsed top-down - More efficient: TS is faster at iterating chars than matching templates