Skip to content

Online13/codingame-typescript-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodingGame Template — TypeScript

This environment is for solving CodingGame puzzles / bots in TypeScript under good conditions, instead of writing everything directly in the online editor.

Why this template?

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.

What it gives you

  • 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 (in dist/) that you just copy-paste into the puzzle.
  • Built-in types for readline (in src/type.d.ts). The global readline() 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.

Installation

Examples use npm, but it's not required — any package manager works (bun, pnpm, yarn…).

npm install

Usage

  1. Write your solution in src/: entry point src/main.ts, plus as many files as you want connected via import/export.

  2. Type-check (optional):

    npm run typecheck
  3. Run the tests:

    npm run test
  4. Build the project:

    npm run build
  5. Grab the generated JavaScript file in dist/ and paste it into the CodingGame editor.

Reset

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 reset

Structure

src/
  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.

About

Local TypeScript workflow for CodinGame puzzles — multi-file code, typed readline, Vitest, bundled to a single file with tsup.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors