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