Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

Those working with TypeScript: explain like I'm five years old how you do it

A topic by minsik created Aug 29, 2021 Views: 371 Replies: 4
Viewing posts 1 to 4

I'm facing different obstacles while trying to use it, and the last one was with imports: unless there is something about TIC-80 I do not know, I need to transpile TS code to one single JS file.  Using regular class imports with TS requires me that I should use either amd or System modules. But TIC-80 does not recognize the require function (as transpiled by amd option) nor the System object (used by System option). The message errors are:

ReferenceError: identifier  'define' undefined

and

ReferenceError: identifier 'System' undefined

I've seen a few references of TypeScript being used succesfuly here, so to those that do, I humbly ask: would you mind to describe with details how you do it? Are you having all your code into on single humongous file?

So far I accepted that transpile all my TS files to JS and manually copy and paste it to TIC-80 seemed the best option (since I do not want to deal with movingback and forth all the extra data about tiles, sfx, map, etc under the code on very long comments). If I need a some kind of  complex build process and not being able to use imports on external tools takes away a lot of the main appeals of the platform to me...

To avoid sidetracking, I would prefer to not discuss using other languages at least for now.

Thank you very much for any inputs.

Developer(+1)

Have you seen TSC-80 - TypeScript for the TIC-80 https://github.com/scambier/tic80-typescript

Seems it does all the things you want

I actually did. Unfortunately it is not compatible with version 0.90 yet.

Developer(+1)

Yes, it's not compatible with 0.90 but I saw the author reported he successfully setup it with the new version.

Hey there, I'm the author of tic80-typescript, so I can provide some pointers for you and other interested developers.

tic80-typescript is indeed not compatible with TIC-80 0.90.x due to API changes, sorry about that. Though it is compatible with TIC-80 1.0.x-dev (pro), if you're willing to build it yourself.

The tool itself simply streamlines the usage of typescript for TIC-80:

  • It setups a typescript project with a .d.ts file for the TIC-80 API (yay autocompletion), and a basic tsconfig.json.
  • It compiles your project into a single .js file that is compatible with Duktape, the js engine used by TIC-80.
  • It does not support modules or npm dependencies; those are usually managed by the environment (like Node) or more advanced bundlers (like Webpack)
  • On top of that, it automatically starts TIC-80, injects the compiled code into the game, and watches code changes.

If you have any question or issue, feel free to ask here or on the GitHub repository.