Загрузка видео...

Не удалось загрузить видео

На главную

🔥 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 просмотров • 3 лет назад •via X (Twitter)

Комментарии: 11

Фото профиля Gabriel Vergnaud
Gabriel Vergnaud3 лет назад

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
Gabriel Vergnaud3 лет назад

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

Фото профиля Gabriel Vergnaud
Gabriel Vergnaud3 лет назад

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 💙💛
David Tai 💙💛3 лет назад

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 💙💛
David Tai 💙💛3 лет назад

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

Фото профиля Gabriel Vergnaud
Gabriel Vergnaud3 лет назад

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

Фото профиля Marcelo Terreiro
Marcelo Terreiro3 лет назад

that's some next-level type programming 😮👏

Фото профиля Gabriel Vergnaud
Gabriel Vergnaud3 лет назад

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

Фото профиля Josh
Josh3 лет назад

🤯

Фото профиля Darryl Yeo・d/acc
Darryl Yeo・d/acc3 лет назад

I need this!!

Фото профиля Gabriel Vergnaud
Gabriel Vergnaud3 лет назад

Should I hit the npm publish button?

Похожие видео