gvergnaud / ts-pattern

🎨 The exhaustive Pattern Matching library for TypeScript, with smart type inference.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: return the value directly

gideaoms opened this issue · comments

Hi, congratulations for the lib.

I would like to know if there is a possibility to return the value directly when I don't need to use it.

How it works today:

match(5)
  .when(1, () => "one")
  .when(2, () => "two")
  .otherwise(() => "three or greater")

How I would like it to work:

match(5)
  .when(1, "one")
  .when(2, "two")
  .otherwise("three or greater")

Duplicate of #100.

Duplicate of #100.

Thanks for letting me know, I'll close it.