TypeScript5

TypeScript5 is a cursor rule for Cursor from TheSethRose/DevRules. It costs 932 tokens per session, scanned A, original, MIT.

TypeScript coding guidance covering compiler settings, type definitions, and common patterns for safer application and library code.

In plain words
What is it for?
Use it when configuring tsconfig.json, choosing TypeScript types, designing functions and objects, handling modules or JSX, and preparing libraries to generate declaration files.
Why use it?
It helps avoid weak types and unclear compiler settings that can let errors pass unnoticed or make code harder to maintain.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when configuring tsconfig.json, choosing TypeScript types, designing functions and objects, handling modules or JSX, and preparing libraries to generate declaration files.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/thesethrose/devrules/typescript5
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/TheSethRose/DevRules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for TypeScript5

README.md
[![agentmods](https://agentmods.dev/badge/rules/thesethrose/devrules/typescript5/github.svg)](https://agentmods.dev/rules/thesethrose/devrules/typescript5)
Your own site
<a href="https://agentmods.dev/rules/thesethrose/devrules/typescript5"><img src="https://agentmods.dev/badge/rules/thesethrose/devrules/typescript5/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for TypeScript5

Your own site · 80×15
<a href="https://agentmods.dev/rules/thesethrose/devrules/typescript5"><img src="https://agentmods.dev/badge/rules/thesethrose/devrules/typescript5.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 932 This file is loaded in full into every session.
When invoked 932 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00932 $0.00932
Opus 5.5 $0.00373 $0.00373
Sonnet 5.5 $0.00186 $0.00186
Haiku 4.5 $0.00093 $0.00093

Measured 3mo ago against content hash 304d45225e9d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

TypeScript5 scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/languages/TypeScript5.mdc · 62 lines

How it starts

The opening of the file, as written. The whole thing — 62 lines — stays where its author put it; the contents beside it link to each section on GitHub.

TypeScript Best Practices

tsconfig.json Configuration

  • Enable strict mode (or individual strict flags like strictNullChecks, noImplicitAny, strictFunctionTypes, etc.). This is the most crucial step for leveraging TypeScript's safety features.
  • Configure target and module appropriately for your runtime environment (e.g., ES2022 or higher for modern Node/browsers, appropriate module system like NodeNext or ESNext).
  • Set up baseUrl and paths for non-relative module resolution if needed, especially in larger projects or monorepos.
  • Understand compiler options related to JSX (jsx, jsxFactory, etc.) if using React/JSX.
  • Configure declaration file generation (declaration, declarationMap, outDir) if building a library.

Type System & Definitions

  • Avoid any. Use unknown when the type is truly unknown and perform type checking/narrowing before use.
  • Use explicit types for function parameters, return values, and variable declarations where inference is not sufficient or clear.
  • Prefer specific types over overly broad ones (e.g., string over any, "success" | "error" over string).
  • Use interface for defining the shape of objects or implementing classes.
  • Use type for creating aliases for unions, intersections, tuples, primitives, and using utility types.
  • Leverage built-in Utility Types (Partial, Required, Readonly, Pick, Omit, Record, etc.) to manipulate existing types effectively.
  • Use Generics (<T>) to create reusable components, functions, and types that can work over a variety of types.
  • Use readonly modifiers for properties that should not be reassigned after object creation.
  • Utilize Discriminated Unions (tagged unions) with literal types to create type-safe state machines or variant types.

Type Narrowing & Guards

  • Rely on TypeScript's control flow analysis for automatic type narrowing (e.g., within if checks, switch statements, instanceof checks).
  • Use typeof checks for primitives.
  • Use instanceof checks for classes.
  • Use the in operator to check for property existence.
  • Create custom Type Guard functions (value is Type) for complex validation logic.

Read the full file on GitHub · 62 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 62 lines · 932 tokens per session scan A 304d45225e9d

Subscribe to this mod's changes

TypeScript5 is a cursor rule published in the GitHub repository TheSethRose/DevRules (26 stars, last pushed 1y ago), licensed MIT. It adds 932 tokens to every session, about $0.0037 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

TypeScript5 compared with cursor rules from other repositories

TypeScript5 next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
TypeScript5TheSethRose/DevRulesCursor rule261y agoMITA932Cursor
pyspark-etl-best-practices-cursorrules-prompt-filePatrickJS/awesome-cursorrulesCursor rule41k6mo agoCC0-1.0A3,275Cursor
kotlin-ktor-development-cursorrules-prompt-filePatrickJS/awesome-cursorrulesCursor rule41k6mo agoCC0-1.0A2,078Cursor
kotlin-springboot-best-practices-cursorrules-prompt-filePatrickJS/awesome-cursorrulesCursor rule41k6mo agoCC0-1.0A1,518Cursor
nextjs-tanstack-query-cursorrules-prompt-filePatrickJS/awesome-cursorrulesCursor rule41k6mo agoCC0-1.0A1,847Cursor
go-backend-scalability-cursorrules-prompt-filePatrickJS/awesome-cursorrulesCursor rule41k6mo agoCC0-1.0A1,200Cursor
jest-unit-testing-cursorrules-prompt-filePatrickJS/awesome-cursorrulesCursor rule41k6mo agoCC0-1.0A935Cursor