DanielXMoore / Civet

A TypeScript superset that favors more types and less typing
https://civet.dev
MIT License
1.33k stars 28 forks source link

"is like" pattern matching operator #1199

Closed edemaine closed 2 months ago

edemaine commented 2 months ago

Fixes #391

Most of this PR is code cleanup:

edemaine commented 2 months ago

I think we can add support for other positions in the future, but my thought was that everything else would end up being consumed by the pattern, so last position makes sense.

But we could have conditionals before is like. For example, x? is like ... could make sense as x? and x is like ..., similar to how x? < y? works now. Currently it matches the Boolean x? which isn't terrible useful. Similarly, x < y is like ... could make sense as x < y && y is like ....

UPDATE: Implemented!