Sitemap

Member-only story

✨ Typescript 5.5 With RegEx Syntax Checking

2 min readJun 25, 2024

Typescript 5.5 was announced just several days ago. It includes a lot of interesting features. Especially I like the ones that continue to figure out types properly, so errors aren’t so confusing.

But there’s one quite major new thing in that release that so far is received with mixed feelings among Typescript developers.

Namely, it’s Regex syntax checking.

In Javascript you can use RegEx out of the box. You can provide a regular expression as a string, or, what can be surprising for other developers: right inside the code.

For example to find cat in a cat box you’d write:

/cat/.test("cat in a box")

The first thing on the left is actually a regular expression, the test method is a method of a regular expression object and a phrase is delivered as an argument.

The notation is quite easy to use and really makes working with regular expressions a breeze in Javascript.

But the question is: when regular expressions are checked of they are correct?

And the answer is: at the runtime.

It causes a myriad of problems, especially because writing a nice regular expression is an art of its kind.

In a pursue of fixing that problem, a person hidden under a graphemecluster pseudonym around September created a merge request that was merged to 5.5 version of Typescript.

--

--

Tom Smykowski
Tom Smykowski

Written by Tom Smykowski

I help startups ship stunning, scalable MVPs—fast. With deep frontend expertise and AI-powered development workflows, I build and audit. Programmer

Responses (1)