Skip to content

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

@brainkim

Description

@brainkim

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions