# TypeScript: error TS1128: Declaration or statement expected.

**Code:** `TS1128: Declaration or statement expected` · **Category:** TypeScript · **Seen on:** TypeScript

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/typescript/ts1128-declaration-or-statement-expected)
