bikeshaving / crank

The Just JavaScript Framework
https://crank.js.org
MIT License
2.69k stars 76 forks source link

Better error messages for tagged template function Syntax Errors. #248

Open brainkim opened 1 year ago

brainkim commented 1 year ago

The 0.5 template tag needs better error messages.

jsx`
  <a
    href=${doc.url}
    aria-current=${doc.url === url && "page"}
    class=${css`
      text-decoration: none;
    `}
    "
  >${doc.attributes.title}</a>
`

Throws

file:///Users/briankim/Projects/crank/src/jsx-tag.ts:248
                                                        throw new SyntaxError(
             ^
SyntaxError: Unexpected text `"`

These messages could be nicer. Like how Babel and TypeScript do it. Something that shows the error in context of the line. Maybe we could use a SyntaxError subclass like JSXSyntaxError to make things even clearer.