typia
typia copied to clipboard
A function mix of is and assertType
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.