rjv-ts-code-stylelisted
Install: claude install-skill rjvim/ai-skills
# TypeScript code style
Strict TypeScript and TSX, written so a file can move without breaking and the same code runs in Node, a bundler and a Worker. Apply when you write or move a file; review checks it.
## 1. Imports
Pick by where the target lives:
| Target | Write | Example |
|---|---|---|
| a file in the same folder | `./` | `import { esc } from './svg.ts'` |
| another package | its package name | `import { bind } from '@acme/engine'` |
| elsewhere in a package a bundler builds (browser code, apps) | `@/` (tsconfig `paths`) | `import { layoutOf } from '@/grid/input.ts'` |
| elsewhere in a package Node runs (CLI, servers, libraries Node imports) | `#src/` (package.json `imports`) | `import { StaleBase } from '#src/store.ts'` |
- **Never `../`.** One `../` today becomes `../../../` after the next move, and it hides where the file is.
- Node runs `.ts` by stripping types and never reads tsconfig `paths`. So `@/` in a Node-run package passes the type-check and fails at run time with "module not found"; Node-run packages use `#src/`.
- Declare the Node alias once per package: `"imports": { "#src/*": "./src/*" }`. Node (14.6+), TypeScript, Vitest and esbuild all read it. It must start with `#`: an `@` name means an npm scope.
- Write the real extension (`.ts`, `.tsx`) on every relative and aliased import. Node needs it; `allowImportingTsExtensions` allows it.
- Never reach into another package's files (`@acme/engine/src/...`): import what its `exports` offers, and add to