Six TypeScript rules that keep AI code safe

this is basically “teach cursor not to do weird type goblin stuff,” and i’m into it - the article’s main point is that a few hard rules around unknown, unions, constrained generics, typed.

Quick vid showing how Cursor keeps trying to sneak any into your TypeScript, and how a few rules force it back into unknown + proper narrowing.

Cursor absolutely will try to “just make it work” by sprinkling any around, and the only thing that consistently stops it for me is making the project loud when it does. Turning on noImplicitAny plus an ESLint rule like @typescript-eslint/no-explicit-any forces the annoying-but-correct unknown + narrowing routine because the editor starts yelling immediately.

I’m not totally sure whether Cursor treats tsconfig errors with the same urgency as lint errors, but fwiw lint has been the better shock collar in my setup.

Cursor will happily “fix” a red squiggle by slapping as Foo on it, and that’s worse than any because it looks legit in review. Do you ban type assertions outside tests (or at least require a comment/justification), or do you just rely on code review to catch the quiet as-papering-over-a-hole stuff? I could be wrong here.