TranspilerLS
raw JSON → 0.4.0 verified Fri May 01 auth: no javascript
TranspilerLS is a TypeScript-to-LeekScript transpiler for the LeekWars programming game. Version 0.4.0 compiles TypeScript code written in a specific project structure into LeekWars-compatible scripts, supporting keyword mappings (e.g., const to var, === to ==), for..of to for..in conversion, template literal transformation, console.log to debug conversion, and enum flattening. It automates login and script upload via environment variables. Release cadence is irregular. Differentiators: it handles LeekWars-specific built-ins (LS object) and enforces a project convention for globals. Requires Node >=10.4.0; ships TypeScript types.
Common errors
error Error: Cannot find module 'typescript' ↓
cause Dev dependency typescript is not installed.
fix
Run npm install typescript --save-dev
error Login failed: invalid credentials ↓
cause Missing or incorrect LOGIN/PASSWORD in .env.
fix
Check .env file and ensure LOGIN and PASSWORD are set correctly.
error File 'MyAI' not found. Please create it on LeekWars. ↓
cause The AI file specified in FILE_NAME does not exist on LeekWars.
fix
Create the AI on LeekWars website first.
Warnings
gotcha All TypeScript files must be inside src/editor/; files outside are ignored. ↓
fix Place all source files under src/editor/
gotcha The FILE_NAME environment variable refers to an existing LeekWars AI file; it is not created automatically. ↓
fix Create the AI file on LeekWars website first, then specify its name.
gotcha Template literals are only converted on a single line; multi-line template literals will break. ↓
fix Avoid multi-line template literals in TypeScript source.
gotcha console.log is transformed into debug() with concatenation; it does not support multiple arguments like console.log. ↓
fix Use string concatenation if passing multiple values.
Install
npm install transpiler-ls yarn add transpiler-ls pnpm add transpiler-ls Imports
- LS wrong
abs(1)correctLS.abs(1) - CELL_TYPE wrong
import CELL_TYPE from './globaux/enums'correctimport { CELL_TYPE } from './globaux/enums' - ENABLE_SAVE wrong
ENABLE_SAVEcorrectprocess.env.ENABLE_SAVE
Quickstart
// 1. Create src/editor/main.ts with content:
import { CELL_TYPE } from './globaux/enums';
const x: number = LS.abs(-5);
console.log(x);
// 2. Set .env:
LOGIN=my_login
PASSWORD=my_password
FILE_NAME=MyAI
ENABLE_SAVE=0
ABSOLUTE_PATH_TO_SOURCES=dist/main.js
ABSOLUTE_PATH_TO_ENUMS=dist/enums.js
PRINT_TO_CONSOLE=1
// 3. Run:
npm run start:dev