heroiclabs / nakama-common

The runtime framework for Nakama server.
https://github.com/heroiclabs/nakama
Apache License 2.0
48 stars 57 forks source link

[TS] Nakama-Project-Template Typescript compile npx tsc fails On MatchSignal is missing in type... #45

Closed crazedVic closed 3 years ago

crazedVic commented 3 years ago

i noticed a new commit here 143e8d8ce05ed3f25200976ad06f435876359806 adding MatchSignal. The template has not been updated to support this perhaps?

i do the recommended npm install and then npx tsc and get this now:

C:\Users\user\projects\nakama\server\nakama-project-template>npx tsc
main.ts:23:43 - error TS2345: Argument of type '{ matchInit: nkruntime.MatchInitFunction; matchJoinAttempt: nkruntime.MatchJoinAttemptFunction; matchJoin: nkruntime.MatchJoinFunction; matchLeave: nkruntime.MatchLeaveFunction; matchLoop: nkruntime.MatchLoopFunction; matchTerminate: nkruntime.MatchTerminateFunction; }' is not assignable to parameter of type 'MatchHandler'.
  Property 'matchSignal' is missing in type '{ matchInit: nkruntime.MatchInitFunction; matchJoinAttempt: nkruntime.MatchJoinAttemptFunction; matchJoin: nkruntime.MatchJoinFunction; matchLeave: nkruntime.MatchLeaveFunction; matchLoop: nkruntime.MatchLoopFunction; matchTerminate: nkruntime.MatchTerminateFunction; }' but required in type 'MatchHandler'.

 23     initializer.registerMatch(moduleName, {
                                              ~
 24         matchInit,
    ~~~~~~~~~~~~~~~~~~
...
 29         matchTerminate,
    ~~~~~~~~~~~~~~~~~~~~~~~
 30     });
    ~~~~~

  node_modules/nakama-runtime/index.d.ts:804:9
    804         matchSignal: MatchSignalFunction;
                ~~~~~~~~~~~
    'matchSignal' is declared here.

Found 1 error.
crazedVic commented 3 years ago

Furthermore reverting to a previous commit:

  "dependencies": {
    "nakama-runtime": "github:heroiclabs/nakama-common.git#32e907f95d02159ca9aa90d79d5ec28528b87f22"
  },

allows the npx tsc to complete successfully.

This issue breaks the introduction tutorial for typescript.

novabyte commented 3 years ago

Thanks @crazedVic. We'll take a look. The types should be simple to update as the server has the match signal functionality in the JS runtime already.

sesposito commented 3 years ago

@crazedVic can you please link the tutorial you're following? It may need an update as well.

crazedVic commented 3 years ago

This is the tutorial https://heroiclabs.com/docs/nakama/tutorials/js/xoxo/ and this is the instructions, they are just in the readme for the sample template projectm which i believe the above tutorial linked to: https://github.com/heroiclabs/nakama-project-template/blob/master/README.md

sesposito commented 3 years ago

@crazedVic I've updated the template with the missing signal function, it should solve the issue whe so I'll close this but let us know if you run into more trouble and we'll reopen if needed.