• Error
  • Reported by the lexer and parser

TS1382

Unexpected token. Did you mean `{'>'}` or `>`?

A `>` appears in JSX text. Write `{'>'}` or `>` to show the character, or check for a malformed tag.

What it means

A bare > in JSX text is not allowed; it often means a tag was closed twice or an attribute was written wrongly. To show the character itself, it has to be escaped.

Example

index.tsx
export const a = <div>></div>;
tsconfig.json
{
  "compilerOptions": {
    "strict": true,
    "target": "es2022",
    "module": "esnext",
    "moduleResolution": "bundler",
    "noEmit": true,
    "jsx": "preserve"
  }
}
ts-r-check -p tsconfig.json --pretty false ts-r output
index.tsx(1,23): error TS1382: Unexpected token. Did you mean `{'>'}` or `&gt;`?

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01.

How to fix

  • Fix the tag if the > is a typo.
  • To display it, write {'>'} or &gt;.