Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

🔥 Built a smarter regex constructor this weekend 🔥 The output of `.exec` is inferred from capturing groups and it supports *named* groups too! Would you use it if this was open source? #TypeScript

47,979 görüntüleme • 3 yıl önce •via X (Twitter)

11 Yorum

Gabriel Vergnaud profil fotoğrafı
Gabriel Vergnaud3 yıl önce

More features I could add: - check if your regex string is valid - automatically coerce number patterns like `[0-9]` to number - Add this to TS-Pattern?

Gabriel Vergnaud profil fotoğrafı
Gabriel Vergnaud3 yıl önce

Here is the code if you want to take a look (it's pretty complex) 👉

Gabriel Vergnaud profil fotoğrafı
Gabriel Vergnaud3 yıl önce

By the way, if you want to learn how I build this kind abstractions with smart type inference, you should read Type-Level TypeScript! It features a tom of free content + paid chapter for deep dive in more advanced concepts

David Tai 💙💛 profil fotoğrafı
David Tai 💙💛3 yıl önce

Nice! I’ve been working on something similar for a while too, currently on third rewrite and almost done😂 two modes: infer all exact matched literal string or all possible matches as hint

David Tai 💙💛 profil fotoğrafı
David Tai 💙💛3 yıl önce

It’s interesting to find that /t extends `${number}`, same goes to /r, /n…etc Any ideas? @mattpocockuk Thanks

Gabriel Vergnaud profil fotoğrafı
Gabriel Vergnaud3 yıl önce

@mattpocockuk That's definitely odd. Have you checked if there is an open issue about this?

Marcelo Terreiro profil fotoğrafı
Marcelo Terreiro3 yıl önce

that's some next-level type programming 😮👏

Gabriel Vergnaud profil fotoğrafı
Gabriel Vergnaud3 yıl önce

Yes! I teach how to do these kinds of things here (in case you don't already know)

Josh profil fotoğrafı
Josh3 yıl önce

🤯

Darryl Yeo・d/acc profil fotoğrafı
Darryl Yeo・d/acc3 yıl önce

I need this!!

Gabriel Vergnaud profil fotoğrafı
Gabriel Vergnaud3 yıl önce

Should I hit the npm publish button?

Benzer Videolar