This environment is for solving CodingGame puzzles / bots in TypeScript under good conditions, instead of writing everything directly in the online editor.
The CodingGame editor is limited: a single file, which gets hard to organize as the code grows. Here you code locally, cleanly structured, then generate a file ready to paste into CodingGame.
- Split your code across multiple files using standard
import/export. You can isolate logic, utilities, data structures, etc., instead of cramming everything into one file. - Compile to a single JavaScript file with tsup. CodingGame only accepts one file: the bundler automatically merges all your code and its imports into a single
.js(indist/) that you just copy-paste into the puzzle. - Built-in types for
readline(insrc/type.d.ts). The globalreadline()function used by CodingGame is already declared, so you get autocompletion and type checking out of the box. - Write and run tests with Vitest. You can unit-test your logic locally before pasting it into CodingGame, instead of debugging blindly in the online editor.
Examples use npm, but it's not required — any package manager works (bun, pnpm, yarn…).
npm install-
Write your solution in
src/: entry pointsrc/main.ts, plus as many files as you want connected via import/export. -
Type-check (optional):
npm run typecheck
-
Run the tests:
npm run test -
Build the project:
npm run build
-
Grab the generated JavaScript file in
dist/and paste it into the CodingGame editor.
src/ ships with a small example bot just to show the setup works (multiple files, imports/exports, build). When you start a real puzzle, reset src/ to a minimal main.ts + type.d.ts with:
npm run resetsrc/
main.ts # solution entry point
type.d.ts # CodingGame global types (e.g. readline)
tests/ # Vitest test files (*.test.ts)
scripts/
reset.mjs # removes the example and restores a minimal project
dist/ # bundled JS file to paste into CodingGame (generated)
tsup.config.ts # bundler config (entry: src/main.ts, output: dist/)
tsconfig.json # TypeScript config
Formatting is handled by Prettier, compilation by tsup, and testing by Vitest.