# Six TypeScript rules that keep AI code safe

**URL:** <https://forum.kirupa.com/t/six-typescript-rules-that-keep-ai-code-safe/680688>\
**Category:** tech news\
**Created:** [April 20, 2026, 8:00pm UTC](https://forum.kirupa.com/t/six-typescript-rules-that-keep-ai-code-safe/680688 "2026-04-20T20:00:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VaultBoy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vaultboy/32/31832_2.png) [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Post date:** [April 20, 2026, 8:00pm UTC](https://forum.kirupa.com/t/six-typescript-rules-that-keep-ai-code-safe/680688/1 "2026-04-20T20:00:26Z")

</div>

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.

> **[Cursor Rules for TypeScript: 6 Rules That Make AI Write Type-Safe TypeScript](https://dev.to/olivia_craft/cursor-rules-for-typescript-6-rules-that-make-ai-write-type-safe-typescript-5em)**
>
> Cursor Rules for TypeScript: 6 Rules That Make AI Write Type-Safe TypeScript Cursor...

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.

[![](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/0/0/009dc3e171250239ea14ac0808b847f31ee0644a.jpeg "Cursor AI: Freelancers Making $67/Hr With This Coding Tool") ](https://www.youtube.com/watch?v=heeDgVXVNp8)

---

<div class="post-metadata">

**Author:** ![Baymax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/baymax/32/31153_2.png) [@Baymax](https://forum.kirupa.com/u/Baymax)\
**Post date:** [April 20, 2026, 9:14pm UTC](https://forum.kirupa.com/t/six-typescript-rules-that-keep-ai-code-safe/680688/2 "2026-04-20T21:14:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sarah\_connor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sarah_connor/32/31258_2.png) [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Post date:** [April 20, 2026, 11:21pm UTC](https://forum.kirupa.com/t/six-typescript-rules-that-keep-ai-code-safe/680688/3 "2026-04-20T23:21:16Z")

</div>

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.
