Skip to content
Get Free Trial

TypeScript Support

Sahi allows scripts to be written in TypeScript. TypeScript .ts files need to be first compiled to JS and then executed via Sahi.

  1. Node.js must be installed in the system.
  2. TypeScript must be installed in the system.
  1. Copy <SahiPro>/userdata/scripts/sahitests/typescript/sahi_apis.ts file in your TypeScript workspace.

  2. Create tsconfig.json in your workspace, if not exist and put the following contents

    {
    "compileOnSave": true,
    "compilerOptions": {
    "target": "es3",
    "outDir": "<SahiPro>/userdata/scripts/sahitests/typescript/out"
    }
    }
  3. Open the TypeScript workspace in MS Code and build the project.

    Go to: Tasks -> Run Build Task -> tsc:build

    Or,

    Open a command prompt/bash, cd to TypeScript workspace and run tsc.

  4. It will build the TypeScript workspace and create JavaScript files in <SahiPro>/userdata/scripts/sahitests/typescript/out directory.

  5. Open the JavaScript files in Sahi Pro Editor and run the script.