Learn TypeScript in Construct, part 1: Getting started

UpvoteUpvote 9 DownvoteDownvote

Index

Features on these Courses

Attached Files

The following files have been attached to this tutorial:

.c3p

learn-ts-part-1.c3p

Download now 50.36 KB

Stats

362 visits, 482 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY-NC 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 19 Jun, 2025.

Adding TypeScript code in an event sheet

As an easy way to get started, let's write our first line of code in an event sheet. First open the Construct editor and create a new empty project, making sure Start with is set to Event sheet.

Creating a new project

Then click the Event sheet 1 tab to switch to the event sheet view.

Switching to event sheet tab

Now add an On start of layout event:

  1. Click Add event in the event sheet tab
  2. Double-click System
  3. Double-click On start of layout (in the Start & end group)

You should end up with this:

On start of layout

This is an event block that will run its actions on startup.

We can add some TypeScript code in the place of an action in this event block, so our code runs on startup. Click Add... to the right of the block, and select Add TypeScript.

Adding a TypeScript action.

A text field appears as an action. This is a small script editor where you can enter some TypeScript code to run.

Editing a script action

For now, let's just copy-and-paste in the following line of code in to that text field:

console.log("Hello world!");

Note if you switch away to a different window, the script editor may finish and change in to an empty code block. If that happens, double-click the empty code block to edit it again, and then paste in or copy out the code sample above. Then click outside the script editor, or press Ctrl + Enter, to close the script editor.

You should now see your first line of TypeScript code in the event sheet!

Your first line of TypeScript code!

This line of code will log the message Hello world! to the browser console on startup. We'll find how to see that message shortly. To help get you started quickly we're not going to fully explain every part of this code just yet - this guide will go in to detail on it later on. For now though here is a brief summary of what this line of code means:

  • console.log means "access the log function on the console object"
  • The parenthesis ( and ) mean "call the log function"
  • "Hello world!" is some text, provided inside double-quotes, that is passed to the log function.
  • The semicolon ; at the end marks the end of a statement

The end result means "add a message with the text Hello world! to the console". Let's find out how to see our message!

Next Tutorial In Course

Learn TypeScript in Construct, part 2: language basics 19:40

Learn some of the basic features of the TypeScript programming language, such as comments, variables and data types.

  • 2 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Im started with it, Lets begin with typescript 🌝

  • it's not really clear for me how to use the behaviours events. Does anybody has any information about it and about construct 3 life circle. I can't find appropriate information about it