colyseus / colyseus.js

⚔ Colyseus Multiplayer SDK for JavaScript/TypeScript
https://docs.colyseus.io/getting-started/javascript-client/
MIT License
410 stars 107 forks source link

Type Error #63

Closed nartc closed 4 years ago

nartc commented 4 years ago

Hi,

I just initialized a Colyseus project with Angular 8. As soon as I start the angular client, I got some typings error:

ERROR in node_modules/@colyseus/schema/lib/Schema.d.ts:54:73 - error TS2536: Type 'K' cannot be used to index type 'this'.

54     listen<K extends NonFunctionProps<this>>(attr: K, callback: (value: this[K], previousValue: this[K]) => void): void;
                                                                           ~~~~~~~
node_modules/@colyseus/schema/lib/Schema.d.ts:54:97 - error TS2536: Type 'K' cannot be used to index type 'this'.

54     listen<K extends NonFunctionProps<this>>(attr: K, callback: (value: this[K], previousValue: this[K]) => void): void;
endel commented 4 years ago

Hi @nartc, this question popped a while ago on Discord:

If possible can you upgrade your Angular to 9 beta? Angular 8 forces a previous version of TypeScript.

I've managed to get TypeScript 3.6+ working on Angular 8 by doing this though, which is a bit ugly:

tsconfig.json

  "angularCompilerOptions": {
    "disableTypeScriptVersionCheck": true
  }

index.html

<script>
  // Workaround for using TypeScript 3.6+
  var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }
</script>
nartc commented 4 years ago

@endel wow that was quick. Thanks so much for the quick response. It's quite crucial as we want to use Colyseus for Game Jam today :D And yes, Angular 9 beta upgrade isn't a problem at all. Thanks again

endel commented 4 years ago

Awesome, good luck with the game jam! Feel free to post your game on #showcase in the forums or Discord! :)