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, this page covers the key differences and patterns you need to be aware of.
JavaScript and TypeScript
- JavaScript
- The programming language of the web. It's dynamically typed, meaning variable types are resolved at runtime rather than at compile time.
- TypeScript
- 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. ScriptRunner only ever runs JavaScript; TypeScript is purely a developer experience improvement.
For Groovy developers, TypeScript feels 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. You write TypeScript and ScriptRunner runs it directly, with no build step to set up and no compiled output to manage.
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. See Groovy vs TypeScript Basics and TypeScript Syntax Quick Reference.
- Asynchronous programming: In Groovy, API calls are synchronous. In TypeScript, they return Promises and require
async/await. This is the biggest conceptual shift. See Understanding Async and Await. - Making HTTP requests: In Groovy, you used Unirest or HttpBuilder. In TypeScript, you use the built-in Fetch API. See Make API Calls with Fetch.
The underlying logic of your scripts translates directly. The language is different; the thinking is the same.