0

I have the classes....

export class CustomField extends GenericField {

   @observable customProperty
    
}

class GenericField {

   @observable genericProperty

}

I ran the codemod to upgrade Mobx as per..... https://mobx.js.org/migrating-from-4-or-5.html

The codemod simply added

constructor() {
   makeObservable(this);
}

To the base class (not the child class) and came up with the error:

/src/CustomField.ts Transformation error (Cannot read property 'start' of null) TypeError: Cannot read property 'start' of null

I am unsure of what to do next? The documentation is not clear in this regard https://mobx.js.org/migrating-from-4-or-5.html#limitations-of-mobx-undecorate it says if base classes expect arguments the codemod will not work. But it doesn't expect anything.

If I run the codemod again it adds yet another call to makeObservable in the base class but nothing changes on the child.

Any ideas?

Exitos
  • 29,230
  • 38
  • 123
  • 178
  • Does it work if you put `makeObservable(this);` in the child class manually? Might be a shortcoming of the codemod if that's the case, might be worth opening an issue for it. – Tholle Dec 27 '20 at 17:59
  • I tried that, it worked well until I had to actually pass parameters. At which point I wasn't sure what to do. And then passed them anyway, and then like 300 tests broke. I was hoping for more clarity around what I should do rather than guessing since the codebase is so big! – Exitos Dec 28 '20 at 09:26

0 Answers0