Weird problem in the class, possibly serialization?

Okay, I’ve been in this problem for a while, and I decided to ask for help. I am getting a curious problem when loading saves into my project.


The “countdown” property is not set. Okay, I traced this back to the origin, which is the class of spells, the only one that deals with this property.

class Spell {
    constructor(propData: spellProp) {
        if (!propData) {
            throw new TypeError(`Spell main class is indefined! "${propData}"`)

        this.prop = propData;
        this.prop.effect = () => {
            Spell effect function, doesn't deal with "countdown" property ...

    // Serialization methods working properly, I think
    clone() {
        return new Spell(clone(this.prop))

    toJSON() {
        return JSON.reviveWrapper('new setup.Spell($ReviveData$)', clone(this.prop))
    Setters and getters...

But the problem seems to be related to the spells declared with that class, which are stored in State.variables.

// Global list
State.variables.globalSpells = {
    minorFlame : new Spell({
        id: "minorFlame", 
        name: "Minor flame", 
        element: "fire",
        damage: window.Util.randomNum(2, 3),
        countdown: [3, 0],
        panel: `...`,
        cost: 3,
        multiEffect: true,
        turnEffect: { 
            source: 'minorFlame',
            name: 'Burning',
            iconClass: `minorFlame`,
            multiEffect: true,
            paralysis: false,
            turns: 2, 
            setEffect: () => {
       -= window.Util.randomNum(2, 3)
            remEffect: false,
            desc: `...`
        effect: () => {}
    Other spells...

If I remove the global spell object, the error does not occur and the save is loaded normally. So, am I doing something wrong by declaring spells that way? I don’t know what’s going on, I thank anyone who can help with that.

A note, if I keep this in setup, this error does not occur. So, in the setup scope, this is being saved, but in the scope of global variables, this is not.