Skip to content

Modern TypeScript patterns. Strict mode, discriminated unions, satisfies operator, const assertions.

License

Notifications You must be signed in to change notification settings

ofershap/typescript-best-practices

Repository files navigation

TypeScript Best Practices

License: MIT Skills

Modern TypeScript 5.x patterns your AI agent should use. Strict mode, discriminated unions, satisfies operator, const assertions, branded types, NoInfer, using, and type-safe patterns.

AI coding assistants default to any, skip strict mode, use as instead of satisfies, and model states with optional fields instead of discriminated unions. This plugin enforces the patterns that make TypeScript worth using.

Install

Cursor / Claude Code / Windsurf

npx skills add ofershap/typescript-best-practices

Or copy skills/ into your .cursor/skills/ or .claude/skills/ directory.

What's Included

Type Name Description
Skill typescript-best-practices 13 rules for strict mode, satisfies, discriminated unions, branded types, NoInfer, and more
Rule best-practices Always-on behavioral rule that enforces current TypeScript patterns
Command /audit Scan your codebase for TypeScript anti-patterns

What Agents Get Wrong

What the agent writes What you should use
any for uncertain types unknown with type narrowing
as SomeType to silence errors satisfies SomeType for validation without widening
{ success?: Data; error?: string } Discriminated union with type field
strict: false in tsconfig strict: true with proper null handling
import { SomeType } import type { SomeType } for type-only imports
TypeVar + Generic[T] patterns NoInfer<T>, const assertions, branded types

Related Plugins


If this helped your workflow, a star helps others find it.

Author

Made by ofershap

LinkedIn GitHub

License

MIT

About

Modern TypeScript patterns. Strict mode, discriminated unions, satisfies operator, const assertions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •