• Error
  • Reported by the lexer and parser

TS1381

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

A `}` appears in JSX text. Write `{'}'}` or `}` to show the character, or remove the stray brace.

What it means

In JSX text, { and } delimit expressions. A lone } in text is usually a leftover brace from editing, and is a syntax error. 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 TS1381: Unexpected token. Did you mean `{'}'}` or `&rbrace;`?

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

How to fix

  • Remove the stray brace if it's a typo.
  • To display it, write {'}'} or &rbrace;.