Files
plane/docs/TYPESCRIPT.md
T
fe034fc262 [WEB-6106] chore: migrate CLAUDE.md to AGENTS.md with symlinks (#5517)
* chore: migrate CLAUDE.md to AGENTS.md with symlinks
- Renamed all CLAUDE.md files to AGENTS.md (open standard)
- Created CLAUDE.md symlinks pointing to AGENTS.md for Claude Code compatibility
- Added .cursorrules symlink at root for Cursor support
- Removed directory structure sections from AGENTS.md files (file paths go stale)
- Preserved domain knowledge: models, endpoints, patterns, configuration

* chore: refactor AGENTS.md files for progressive disclosure

- Remove directory structures from authentication and db AGENTS.md (file paths go stale)
- Move 667-line design system guide from packages/tailwind-config/AGENTS.md to docs/design-system.md
- Replace tailwind-config AGENTS.md with 30-line summary linking to full docs

* chore: add AGENTS.md to web apps with design system links

- Add AGENTS.md for apps/web, apps/admin, apps/space
- Link to docs/design-system.md for Canvas/Surface/Layer patterns
- Create CLAUDE.md symlinks for Claude Code compatibility

* chore: add docs/TYPESCRIPT.md and link from all TS packages

- Create docs/TYPESCRIPT.md with modern TypeScript conventions (5.0+)
- Rename docs/*.md files to CONSTANT_CASE
- Add AGENTS.md to all TypeScript packages with links to docs
- Add AGENTS.md to apps/live and apps/relay
- Update app AGENTS.md files with TypeScript and feature doc links
- Link CALENDAR_IMPLEMENTATION.md from apps/web
- Link OIDC_GROUP_SYNCING.md from apps/api/plane/authentication
- Delete unused todesktop-implementation-guide.md
- Create CLAUDE.md symlinks for all new AGENTS.md files

* fix: claude.md files symlinks

---------

Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
2026-02-02 16:42:43 +05:30

2.4 KiB

TypeScript Guidelines

Modern TypeScript conventions for Plane (v5.0+).

Key Principles

  1. Use modern features - const type parameters, satisfies, using declarations
  2. Prefer erasable syntax - Avoid enums and namespaces; use const objects or unions
  3. Explicit type imports - Use import type for type-only imports (verbatimModuleSyntax)
  4. Trust inference - Let TypeScript infer where possible, annotate at boundaries

Type System

// const type parameters for literal inference
declare function names<const T extends string[]>(...names: T): void;

// satisfies for validation without widening
const config = { port: 3000 } satisfies Config;

// NoInfer to block inference
function create<T>(value: T, defaultValue: NoInfer<T>): T;

Resource Management

// using declarations (5.2+) for automatic cleanup
using resource = new Resource();
// resource.dispose() called automatically at block end

Imports

// Type-only imports (required with verbatimModuleSyntax)
import type { User } from "./types";
import { createUser, type UserOptions } from "./users";

// Import attributes for JSON
import data from "./data.json" with { type: "json" };

Modern APIs

// Object.groupBy instead of lodash
const grouped = Object.groupBy(items, (item) => item.category);

// Copying array methods for immutability
const sorted = arr.toSorted();
const modified = arr.with(0, newValue);

// Promise.withResolvers
const { promise, resolve, reject } = Promise.withResolvers<T>();

Avoid

Avoid Prefer
enum Foo {} const Foo = { ... } as const or union types
namespace ES modules
import ... assert import ... with
Explicit any unknown with narrowing
Manual cleanup using declarations

Narrowing

TypeScript handles these automatically:

  • switch(true) blocks
  • Boolean comparisons
  • Closures (when variable isn't reassigned)
  • Constant indexed access (obj["key"] where "key" is const)

Configuration

Projects use --moduleResolution bundler and --verbatimModuleSyntax. See ESLINT.md for linting rules.