typescript

typescript is a cursor rule for Cursor from heyAyushh/stacc. It costs 0 tokens per session (2,196 once invoked), scanned A, original, MIT.

A set of TypeScript practices for making JavaScript and TypeScript code safer through strict checks, clear types, and validation of external data.

In plain words
What is it for?
Use it when configuring TypeScript, checking JavaScript files, defining types, or validating data received from outside the program.
Why use it?
It helps catch type-related mistakes before the program runs and reduces problems caused by missing, null, or incorrectly shaped values.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { formatCurrency } from '../utils/formatters';.

Good fit Use it when configuring TypeScript, checking JavaScript files, defining types, or validating data received from outside the program.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/heyAyushh/stacc
agentmods
npx agentmods add rules/heyayushh/stacc/typescript

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 typescript

README.md
[![agentmods](https://agentmods.dev/badge/rules/heyayushh/stacc/typescript.svg)](https://agentmods.dev/rules/heyayushh/stacc/typescript)
Your own site
<a href="https://agentmods.dev/rules/heyayushh/stacc/typescript"><img src="https://agentmods.dev/badge/rules/heyayushh/stacc/typescript.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,196 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.02196
Opus 5 $0.00000 $0.01098
Sonnet 5 $0.00000 $0.00439
Haiku 4.5 $0.00000 $0.00220

Measured 4d ago against content hash 25aba04f0c46, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

typescript 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 4d 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.

configs/stacks/nextjs/rules/typescript.mdc · 313 lines

How it starts

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

TypeScript Best Practices (for JS/JSX Type-Checking)

This guide outlines essential TypeScript best practices for teams working with JavaScript or JSX files that are type-checked by TypeScript (e.g., via tsconfig.json with allowJs and/or JSDoc annotations). While many examples use native TypeScript syntax for clarity and conciseness, the underlying principles and type-safety benefits apply directly to your .js/.jsx codebase.

1. Enable Strict Mode in tsconfig.json

This is the single most impactful change you can make. strict: true enables a suite of crucial checks that catch the vast majority of common type-related bugs at compile time.

Action: Ensure your tsconfig.json includes:

// tsconfig.json
{
  "compilerOptions": {
    "strict": true, // Enables all strict type-checking options
    "noImplicitAny": true, // Catches untyped variables/parameters
    "strictNullChecks": true, // Prevents `null`/`undefined` access without checks
    "strictPropertyInitialization": true, // Ensures class properties are initialized
    "allowJs": true, // Crucial for type-checking .js/.jsx files
    "checkJs": true, // Enables type-checking in .js/.jsx files
    // ... other options
  },
  "include": ["**/*.js", "**/*.jsx"] // Ensure your JS/JSX files are included
}

2. Define Clear Type Contracts

Use interfaces and type aliases to describe the shape of your data, especially for API payloads, component props, and complex objects. For .js/.jsx files, leverage JSDoc to apply these types.

✅ GOOD: Interfaces for Object Shapes & Classes

Interfaces are ideal for defining the shape of objects and for implementing explicit contracts when working with classes. Define these in .d.ts or .ts files, then reference them in JSDoc.

// types.d.ts or types.ts
interface UserProfile {
  id: string;
  name: string;
  email: string;
  age?: number; // Optional property
}

interface Point {
  readonly x: number;
  readonly y: number;
}

Read the full file on GitHub · 313 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. 4d ago First seen · 313 lines · 0 tokens per session scan A 25aba04f0c46

Subscribe to this mod's changes

typescript is a cursor rule published in the GitHub repository heyAyushh/stacc (3 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,196 tokens. 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-09-03.