Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. metiscoda
  3. Posts
  • Profile
  • More
    • Continue chat with metiscoda
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

Posts made by metiscoda

Schema with references to another declared elsewhere (sovled)

Hi,
I'm trying to start my server, and it tells me it is having trouble compiling one of my schema files (at the line where it refers to another schema defined in another file). I can bring it into the same file but it still has the problem that it references this schema in the other schema as well.

e.g:

export class KawadiPlayer extends Schema {

  @type("int8")
  teamColor : number;

  @type("boolean")
  isPromoted : boolean;

  @type(KawadiTest)
  teamHome : KawadiTest;

while KawadiTest is defined like so:

import { Schema, type } from "@colyseus/schema";
import { KawadiPlayer } from "./KawadiPlayer";

export class KawadiTest extends Schema {

    @type(KawadiPlayer)
    owner : KawadiPlayer;
}

It gives me an error when I start this server, complaining about :

TypeError: Cannot read property 'map' of undefined
    at Function.MapSchema.is (/Users/alampara/Documents/Colyseus/colyseus-kawadi/node_modules/@colyseus/schema/src/types/MapSchema.ts:64:20)
    at /Users/alampara/Documents/Colyseus/colyseus-kawadi/node_modules/@colyseus/schema/src/annotations.ts:205:45
    at __decorate (/Users/alampara/Documents/Colyseus/colyseus-kawadi/src/rooms/schema/KawadiTest.ts:5:110)
    at Object.<anonymous> (/Users/alampara/Documents/Colyseus/colyseus-kawadi/src/rooms/schema/KawadiTest.ts:7:5)
    at Module._compile (module.js:653:30)
    at Module._compile (/Users/alampara/Documents/Colyseus/colyseus-kawadi/node_modules/source-map-support/source-map-support.js:547:25)
    at Module.m._compile (/private/var/folders/tm/w9wrv6315kv7wvy94gwvh4780000gq/T/ts-node-dev-hook-44659108076979726.js:69:33)
    at Module._extensions..js (module.js:664:10)
    at require.extensions..jsx.require.extensions..js (/private/var/folders/tm/w9wrv6315kv7wvy94gwvh4780000gq/T/ts-node-dev-hook-44659108076979726.js:114:20)
    at require.extensions.(anonymous function) (/private/var/folders/tm/w9wrv6315kv7wvy94gwvh4780000gq/T/ts-node-dev-hook-44659108076979726.js:71:20)
[ERROR] 20:52:47 TypeError: Cannot read property 'map' of undefined

Would I be able to have cross references between two types?
Thanks for any help you can provide.

posted in Questions & Help • 2 Jul 2021, 03:56

© 2023 Endel Dreyer