tsafe icon indicating copy to clipboard operation
tsafe copied to clipboard

Ability to trigger warnings instead of errors

Open Amatewasu opened this issue 1 year ago • 1 comments

Hi, thank you a lot for this great library.

I don't know if it's doable but it would be so great to be able to trigger warnings instead of errors.

One example of a use case is that I check that I handled all the cases, thereby in the future if I add a case, I don't forget to handle it in this piece of code. But when I create a case, I may want to test other parts of the code before handling it here.

const foo: a | b | c = ...;
if (isA(foo)) { ... }
else if (isB(foo)) { ... }
else if (isC(foo)) { ... }
else {
  // we check that we handled all the cases, thereby if we add a case in the future, we will trigger an error
  assert<Equals<typeof foo, never>>();
}

Amatewasu avatar Dec 16 '22 12:12 Amatewasu