A C-like scripting language, built upon Typescript
npm install escriptts
// app.es
interface Car {
string make;
};
Car myCar = {
make: "Chevrolet"
};
// output: Chevrolet
log myCar.make;
class Vehicle {
private string make;
private string model;
public constructor(string make, string model) {
this.make = make;
this.model = model;
}
public string displayInfo() {
return this.make + " " + this.model;
}
protected void updateModel(string newModel) {
this.model = newModel;
}
}
Vehicle myCar2 = new Vehicle("Ford", "Mustang");
// output: Ford Mustang
log myCar2.displayInfo();
`
CLI Features
- Compile Escript to TypeScript: Converts Escript code into TypeScript.
- Transpile TypeScript to JavaScript: Converts TypeScript code into JavaScript using the TypeScript compiler (tsc).
- Execute JavaScript: Run the final JavaScript output directly from the command line.
- Interactive Help: Provides help and usage instructions directly via CLI.
Installation
You can install Escript CLI globally using npm or yarn:
`bash
npm install -g escript
or
yarn global add escript
`
Usage
$3
To compile an Escript file, use the following command:
`bash
npx esc -i -o
`
- -i, --input Path to the input Escript file.
- -o, --output Path to the output JavaScript or TypeScript file.
$3
- -t, --transpile: Transpile the resulting TypeScript code to JavaScript. If this flag is used, the output path should be for a TypeScript file (.ts), and the final output will be a JavaScript file (.js).
- -r, --run: Run the final JavaScript file after transpilation. This option requires that the -t flag is also set.
$3
Compile Escript to TypeScript:
`bash
npx esc -i myscript.es -o output.ts
`
This command converts myscript.es to TypeScript and saves it as output.ts.
Compile and Transpile to JavaScript:
`bash
npx esc -i myscript.es -o output.ts -t
`
This command converts myscript.es to TypeScript and then transpiles output.ts to JavaScript, saving it as output.js.
Compile, Transpile, and Run:
`bash
npx esc -i myscript.es -o output.ts -t -r
`
This command performs the full workflow: compiles myscript.es to TypeScript, transpiles it to JavaScript, and then runs output.js.
Commands
$3
Get started using the Escript CLI tool with the following command:
`bash
npx esc start
`
This command displays a welcome message and basic usage instructions.
Configuration
$3
The CLI uses the TypeScript compiler (tsc) to transpile TypeScript code to JavaScript. Ensure that tsc is installed and accessible from your environment. You can install it globally via npm:
`bash
npm install -g typescript
``