Demo, all content is generated
Question

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

Solved · 211 views · asked by anouk · edited

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

Type error: Property 'ingredients' does not exist on type 'Recipe'.
  > 24 |   {recipe.ingredients.map((i) => (

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 · edited
Found two already, checking for more. Thanks for the hint. anouk · edited

2 answers

Marked as helpful by the asker
sergio_ruiz · edited

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 · edited
Called it :) sofia_gr · edited
pawel_z · edited

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 · edited