Using TypeScript in Construct

29

Stats

4,151 visits, 5,936 views

Tools

Translations

This tutorial hasn't been translated.

License

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

Published on 12 Oct, 2023. Last updated 19 Jul, 2024

This guide has moved

This tutorial on using TypeScript in Construct has been moved to the official manual, in the 'Scripting' section's guides. You can now find the latest documentation here: https://www.construct.net/en/make-games/manuals/construct-3/scripting/guides/using-typescript

  • 4 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Is it possible to make Construct to allow me to write imports like:

    import Globals from "./globals"

    instead of:

    import Globals from "./globals.js";

    without .js at the end.

    When I'm working on TypeScript projects all imports usually omit file extension. This is a bit anoying to manualy change it all the time. I'll see if I can configure my IDE to add .js at the end. But I've been working more than 5 years with TypeScript and never ever I've added any extensions in the imports. Also IDE auto insert imports, and they don't have extensions

      • [-] [+]
      • 2
      • Ashley's avatar
      • Ashley
      • Construct Team Founder
      • 2 points
      • (0 children)

      TypeScript needs to generate JavaScript that refers to a filename like "./globals.js", because that's how it works in the browser. You can configure TypeScript however you like, so long as it outputs that. I think I saw that TypeScript 5.7 is going to be adding some new options around this.

  • this should be added to the manual under guides in scripting section. I missed this the first time I checked as its a hidden link the manual.