GitHub Documentation

Typescript Interfaces for TS client

  • Hi,

    Not sure if I’m missing something in the documentation. Is there a way to export TS Interfaces from the Colyseus project for inclusion in the frontend TS project? Similar to what the CLI tool offers for C#?

  • administrator

    Hi @genox, sure, if you're using webpack you can keep your Schema definitions under a "common" directory and import them from the server-side and client-side.

    So when joining a room through TypeScript in the client-side, you can use:

    var room = client.join<YourRootStateSchema>("room_name");
    room.state // you get auto-completions based on your "YourRootStateSchema" file

    Is this what you're asking for? Cheers

  • Will give it a try, thanks!


© 2021 Lucid Sight, Inc