typia icon indicating copy to clipboard operation
typia copied to clipboard

A function mix of is and assertType

Open ismailkarsli opened this issue 3 years ago • 0 comments

Feature Request

I think an assertion function like Node.js assert would be cool. So instead of writing:

if(!is<T>(untrustedValue)) throw new Error();
// Using untrustedValue

we can write:

assert<T>(untrustedValue)
// Using untrustedValue

assertType is close to this feature but it doesn't predicates the value, instead, returns a predicated value.

I tried to doing this functionality myself but https://github.com/samchon/typescript-json/issues/125 issue wouldn't let me do it. I'm getting the error below.

Error: Error on TSON.is(): non-specified generic argument.

ismailkarsli avatar Sep 20 '22 14:09 ismailkarsli