Updating importsForEvents.ts

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • Using this example from the TypeScript tutorial, GetMessage can be imported from main.ts with either

    	import { GetMessage } from "./main.js";
    

    or

    import * as Main from "./main.js";

    However, once this is done one way, switching to the other, or changing the name for the module, seems to be impossible.

    Is there a way to force importsForEvents to update? This does not seem to be a problem in JavaScript, only TypeScript, and the only workaround I've found is by converting to JS then back to TS.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure what you mean. It's not impossible to change the import - you can change it, but then you might need to update code that references it, because those imports work differently (e.g. with the first you can call GetMessage() directly, with the second you must call Main.GetMessage()).

    I don't know what you mean about forcing importsForEvents to update, nor why JavaScript would do this differently - it should work the same.

  • That is exactly the behavior I expected and did not get. After running the project in Preview once, trying to change the import and event sheet gives an error:

    Or, going the other direction:

    Changing to import * as Main first, running in Preview once, and then using Undo to go back to import {GetMessage} and running in Preview again works fine. I can Undo/Redo back and forth and it will run, but changing it back by typing it out breaks it again.

    I guess this is a bug then. I'll submit a bug report when I get a chance.

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