diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-04-21 12:47:21 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-04-21 12:47:21 +0200 |
| commit | 148d38d7c95c15b8c2746a2d86994f0970536742 (patch) | |
| tree | 61ca30ff808d034703ce049a57585c35231dbfc4 /AGENTS.md | |
| parent | 3e89d2998588f8e35c524e523ba2ee853f0f6475 (diff) | |
| download | opencut-148d38d7c95c15b8c2746a2d86994f0970536742.tar.gz | |
docs: ts conventions to agents.md
Diffstat (limited to 'AGENTS.md')
| -rw-r--r-- | AGENTS.md | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -21,3 +21,17 @@ Each app is a frontend that calls into Rust. Logic is never duplicated between a - Read components before using them. They may already apply classes, which affects what you need to pass and how to override them. +### TypeScript + +Function signatures should make the call site readable and let the function evolve without breaking callers. Positional parameters fail both: `formatTime(30, 24)` hides which number is which, and adding, removing, or reordering an argument silently breaks every caller whose types happen to still line up. A single destructured object fixes both at once - each argument names itself at the call site, and the shape can grow without churn. So signatures default to one object parameter: + +```tsx +// ❌ meaning depends on order; the shape can't evolve without touching every caller +function formatTime(seconds: number, fps: number) { ... } + +// ✅ each argument names itself; fields can be added, reordered, or made optional freely +function formatTime({ seconds, fps }: { seconds: number; fps: number }) { ... } +``` + +The one real exception is type predicates (`element is VideoElement`) — the language requires a positional subject, so the reasoning above doesn't get to apply. + |
