# Fix the TypeScript parser agent failing on satisfies expressions

## TL;DR

The parser's TypeScript support is too old for satisfies, so upgrade the parser or rewrite the expression. satisfies landed in TS 4.9, and older parsers choke on it. Bump the parser dependency past the version that added support, or use a type assertion the old parser understands.

## The error

```text
Parser agent: unexpected token, expected "," 
on: const messages = { a: "x" } satisfies a string-keyed record type
```

## Fix it

### Step 1: Check the parser version

```bash
node -e "console.log(require('typescript/package.json').version, require('@babel/parser/package.json').version)"
```

Expected: You see whether the versions predate satisfies support.

### Step 2: Upgrade the parser

```bash
npm ls typescript | head -3
```

Expected: You see the installed version, then bump to one with satisfies support.

### Step 3: Or rewrite without satisfies as a stopgap

```bash
node -e "console.log('annotate the object with its type instead of using satisfies -- old parsers handle annotations fine')"
```

Expected: The file parses on the old version too.

### Step 4: Re-run the parser agent

```bash
node scripts/parse-messages.js | tail -3
```

Expected: Message files parse cleanly.

## When to use this

- A TS parser agent fails on satisfies expressions
- Message files use modern TS syntax

## When NOT to use this

- The parser fails on all TS, the TS plugin is missing entirely
- Runtime errors about satisfies, that is a tsconfig target issue

## Tool and version compatibility

- TypeScript 4.9+ for satisfies, @babel/parser 7.20+
- typescript-eslint parsers similarly versioned

## Variant phrasings

### fails on other new syntax like using declarations

Same fix. Match the parser version to the syntax you write.

### CI parser differs from local

Lockfiles drift. Pin the parser version in both.

## Why it happens

Parsers implement syntax version by version. satisfies changed the expression grammar, so a parser from before TS 4.9 sees an unexpected token where the new keyword sits and aborts the file.

## Edge cases

- Upgrading the parser can change other parse behavior, run the full suite
- Keep message files on boring syntax, they are read by the most tools
- The agent's bundled parser may differ from your project's, check both

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_DZAXMtJAzvrqwlLb32IrfQ
