How to use "imports for events" with Typescript?

0 favourites
  • 2 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • Hello everyone.

    I'm using beta version 363, and I'm very pleased with TypeScript support. However, I'm having difficulties importing scripts with the "purpose: imports for events" in Construct 3.

    In JavaScript, I simply create a file named "importsForEvents.js" with content similar to this:

    import * as Boids from "./boids.js";
    

    Using TypeScript, I've created the file "importsForEvents.ts" as follows:

    import * as Boids from "./boids.js";
    

    But when TypeScript compiles the code, it produces the "importsForEvents.js" file containing:

    export {};
    

    I can't figure out what I'm doing wrong.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It looks like the TypeScript compiler removes unused imports by default, which doesn't work for importsForEvents.js, because it adds code after the import later on but the TypeScript compiler doesn't know about that.

    It looks like adding the option "verbatimModuleSyntax": true in tsconfig.json fixes this - I'll add that to the next beta so it's a default setting.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)