typescript-project-setup
Installation
SKILL.md
To set up a new repo with TypeScript, follow these steps unless you have reason to deviate from them:
npm install --save-dev typescript@latest(or use the user's package manager of choice)- Run
npx tsc --initto create atsconfig.jsonfile - Read the tsconfig.json it generates and make the edits suggested in that file:
- If running server-side or local scripts, add
nodetotypesandnpm install --save-dev @types/node - Set
rootDirtosrcandoutDirtodist - If using vite, esbuild, or similar bundlers, set
moduleResolutiontobundler- If you have more specific info from the bundler info, defer to it instead
- If running server-side or local scripts, add
- Create a
srcdirectory and add your TypeScript files there - Add a build script to your
package.jsonthat runstsc - If using a bundler, add the appropriate build script for it as well
If you're running TypeScript code on the commandline, tsx is no longer necessary or recommended if node 22.18.0 or later is installed.
Enable erasableSyntaxOnly and rewriteRelativeImportExtensions in the tsconfig and run e.g. node src/index.ts directly.