ts-macros icon indicating copy to clipboard operation
ts-macros copied to clipboard

Improve $$err typing (and fix doc)

Open Gurimarukin opened this issue 1 year ago • 1 comments

  • If the transformation is not possible, $$text expands to "null", not undefined. 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: image Updating, $$err return type to never fixes the problem.

Gurimarukin avatar Nov 23 '23 16:11 Gurimarukin

Thanks for the PR! Will be merged soon

GoogleFeud avatar Dec 17 '23 18:12 GoogleFeud