Navigation

    Colyseus
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. metiscoda
    metiscoda

    metiscoda

    @metiscoda

    Chat Follow Unfollow
    0
    Reputation
    1
    Posts
    483
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Continue chat with metiscoda
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    metiscoda Follow

    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 •