Question

Cursor fixes the same TypeScript error 4 times and it keeps coming back

Solved · 211 viewsasked by anouk

Building a small recipe app in Next.js. This error:

Agent fixes it, build passes, I ask for the next thing (a filter on the list) and the error is back. Now it's the 4th time. Every time it says "I've fixed the type error by updating the Recipe type". I have a demo for my course on friday and I'm getting a bit nervous tbh.

What I’ve tried

Asked it to fix it again (4x), asked it to 'fix it permanently', restarted Cursor once.

Comment
Can you search the project for type Recipe and interface Recipe? I have a feeling there's more than one. sofia_gr
Found two already, checking for more. Thanks for the hint. anouk

2 answers

Marked as helpful by the asker
sergio_ruiz

Classic two-definitions loop. Almost certainly you have Recipe defined twice (say types/recipe.ts and inline in lib/data.ts). Each fix edits one of them, the next feature imports the other one, and the error "comes back".

Break the loop instead of asking for fix #5:

  1. Stop the agent. Search yourself: grep -rn "Recipe\b" --include=*.ts* src app lib.
  2. Pick one definition, delete the other, point every import to the survivor.
  3. Then tell Cursor exactly that as a rule: "The only Recipe type is in types/recipe.ts. Never declare it anywhere else."

General rule for loops: if the same fix happened twice, the model is missing a fact. Asking harder doesn't add the fact; finding it does.

Comment
There were THREE. types/recipe.ts, one in the page file and one in a mock data file. Deleted two, build is green and it stays green. Thank you!! anouk
Called it :) sofia_gr
pawel_z

Also worth adding tsc --noEmit as a step you run yourself after each agent turn (or npm run build). If you only look at what the agent reports, you see its summary, not the compiler.

Comment
Added npm run build to my checklist after each prompt, good point. anouk