ts-macros
ts-macros copied to clipboard
Improve $$err typing (and fix doc)
- If the transformation is not possible,
$$text
expands to"null"
, notundefined
. Corrected doc accordingly.
- You should be able to write this:
function $$textSafe(exp: unknown): string {
const $res = $$text!(exp)
if ($res === 'null') {
return $$err!('$$text: exp in not transformable.')
}
return $res
}
But I get an error:
Updating,
$$err
return type to never
fixes the problem.
Thanks for the PR! Will be merged soon