Scripting in TypeScript
Learn the key differences when moving from Groovy to TypeScript in ScriptRunner, including syntax, async programming, and making HTTP requests.
Whether you're new to TypeScript or an experienced Groovy developer, the following pages focus on the key differences and patterns you need to be aware of:
JavaScript and TypeScript
JavaScript is the programming language of the web. It's dynamically typed, meaning variable types are resolved at runtime rather than at compile time.
TypeScript is a superset of JavaScript. It adds optional static typing, catching errors at the authoring stage rather than at runtime. TypeScript is not a separate runtime; it compiles down to plain JavaScript before execution. The platform only ever runs JavaScript; TypeScript is purely a developer experience improvement.
For Groovy developers, TypeScript will feel familiar: like Java, it uses explicit types and surfaces mistakes early.
TypeScript in ScriptRunner
ScriptRunner for Jira Isolated Cloud is built on Atlassian Forge, and all scripting features use TypeScript. When you save a script, ScriptRunner compiles your TypeScript to JavaScript automatically — you write TypeScript, the platform handles the rest.
What this means for you
Moving from Groovy to TypeScript involves the following main adjustments:
- Syntax differences: TypeScript uses different conventions for variables, functions, objects, and iteration. The Groovy vs TypeScript Fundamentals and TypeScript Syntax Quick Reference pages cover these in detail.
- Asynchronous programming: In Groovy, API calls are synchronous. In TypeScript, they return Promises and require
async/await. This is the biggest conceptual shift, and the Understanding Async and Await page explains it thoroughly. - Making HTTP requests: In Groovy, you used Unirest or HttpBuilder. In TypeScript, you use the built-in Fetch API. The Make API Calls with Fetch page covers this in detail.
The underlying logic of your scripts translates directly. The language is different; the thinking is the same.