TS1128: Declaration or statement expected TypeScript Origin: On your device Last updated 5 Nov 2026

TypeScript: error TS1128: Declaration or statement expected.

The parser found a token where a declaration or statement should start — usually stray braces/parentheses or code outside a function.

Exact message you may see error TS1128: Declaration or statement expected.Declaration or statement expected. ts(1128)TS1128 Declaration or statement expectederror TS1109: Expression expected.error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
Seen on: TypeScript

Meaning

Check for an extra } or ) above the line, missing opening brace, statements placed at the top level of a class body, or a half-pasted snippet. Format with Prettier to reveal mismatched brackets. Also appears when using Flow/JSX syntax in .ts files.

Common causes

  • Extra closing brace/parenthesis
  • Missing opening brace
  • Statement directly inside a class body
  • Pasted partial code
  • JSX/Flow syntax in a .ts file

⚡ Quick fix

  1. Run Prettier/format to see bracket mismatches
  2. Remove the stray } or add the missing {
  3. Move statements into methods/constructors

Detailed fix by platform

Linux

  1. npx prettier --check src/app.ts

How to diagnose

  1. Brackets — Balanced?
  2. Position — Inside class body?
  3. Syntax — JSX in .ts?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Adjacent JSX elements — Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (React)Adjacent JSX elementsalready declared — SyntaxError: Identifier 'x' has already been declared (JavaScript)already declaredawait outside async — SyntaxError: await is only valid in async functions and the top level bodies of modules (JavaScript)await outside asyncCannot find module './App.vue' or its corresponding type declarations — TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations. (Vue)Cannot find module '.…Element is missing end tag — Vue: [plugin:vite:vue] Element is missing end tag. / Invalid end tag. (Vue)Element is missing en…ERR_UNKNOWN_FILE_EXTENSION — TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" (Node.js)ERR_UNKNOWN_FILE_EXTE…invalid regex — SyntaxError: Invalid regular expression: /x/: Unterminated group (JavaScript)invalid regexinvalid token — SyntaxError: Invalid or unexpected token (JavaScript)invalid tokenTS1128: D…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.