Replies: 3 comments 1 reply
-
Every class that introduces observables needs makeObservable, so that
includes the subclass indeed.
Op ma 28 dec. 2020 09:30 schreef Logic Room <notifications@github.com>:
… We have some classes....
export class CustomField extends GenericField {
@observable customProperty
}
class GenericField {
@observable genericProperty
}
We ran the codemod to upgrade Mobx as per the documentation at.....
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*
We are 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 (does this mean through the
constructor?) the codemod will not work. But it doesn't expect anything, so
this statement doesn't make sense and nor does the warning.
If we run the codemod again it adds yet another call to makeObservable in
the base class but nothing changes on the child.
Any ideas what the correct way forward is....?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2691>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBDL4FWHU7M566YMGOLSXBF5FANCNFSM4VLZKHLQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Thanks @mweststrate , in that case I think the codemod has a bug? The documentation says .... The mobx-undecorate command has to introduce a constructor in classes that do not yet have one. If base class of the constructor expects arguments, the codemod cannot introduce these arguments for the subclass being upgraded, and the super call won't pass them either. You have to fix these manually Yet our class (GenericField ) does not have a constructor argument in the base class, so in that case there is no reason the codemod cannot create one in the subclass? Also the warning says... 'Transformation error (Cannot read property 'start' of null)' which isn't clear what the problem is? |
Beta Was this translation helpful? Give feedback.
-
The codemod is a best effort, not a guaranteed correct / complete
conversion, and many things can influence its results, for example certain
Babel syntax extensions might make the file unparsable for the codemod. If
you think a case is missing that should be supported, please PR a unit test
with a reproduction.
Op ma 28 dec. 2020 11:14 schreef Logic Room <notifications@github.com>:
… Thanks @mweststrate <https://github.com/mweststrate> , in that case I
think the codemod has a bug?
The documentation says ....
*The mobx-undecorate command has to introduce a constructor in classes
that do not yet have one. If base class of the constructor expects
arguments, the codemod cannot introduce these arguments for the subclass
being upgraded, and the super call won't pass them either. You have to fix
these manually*
Yet our class (GenericField ) does not have a constructor argument in the
base class, so in that case there is no reason the codemod cannot create
one in the subclass?
Also the warning says... 'Transformation error (Cannot read property
'start' of null)' which isn't clear what the problem is?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2691 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBG3UO7JCNH4LE7F54LSXBSCRANCNFSM4VLZKHLQ>
.
|
Beta Was this translation helpful? Give feedback.
-
We have some classes....
We ran the codemod to upgrade Mobx as per the documentation at..... https://mobx.js.org/migrating-from-4-or-5.html
The codemod simply added
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
We are 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 (does this mean through the constructor?) the codemod will not work. But it doesn't expect anything, so this statement doesn't make sense and nor does the warning.
If we run the codemod again it adds yet another call to makeObservable in the base class but nothing changes on the child.
Any ideas what the correct way forward is....?
Beta Was this translation helpful? Give feedback.
All reactions