Mobx: [undecorate] makeObservable not added to imports

Created on 20 Oct 2020  ·  5Comments  ·  Source: mobxjs/mobx

Starting code

import { decorate, observable, action } from "mobx";

class TestStore
{
  testValue = 1;

  testFunc = () =>
  {
    this.testValue++;
  }
}

decorate(TestStore,
{
  testValue: observable,
  testFunc: action
});

export default TestStore();

Intended outcome:

import { observable, action, makeObservable } from "mobx";

class TestStore
{
  testValue = 1;

  testFunc = () =>
  {
    this.testValue++;
  }

  constructor() {
    makeObservable(this);
  }
}

export default TestStore();

Actual outcome:

import { observable, action } from "mobx";

class TestStore
{
  testValue = 1;

  testFunc = () =>
  {
    this.testValue++;
  }

  constructor() {
    makeObservable(this);
  }
}

export default TestStore();

How to reproduce the issue:

Just run npx mobx-undecorate

Versions

Undecorate 1.0.2

🎁 mobx-undecorate

All 5 comments

Would you mind submitting a PR with a test case with your code that's failing? It's always easier to fix things against tests.

It seems there was no new version released of undecorate, but a new version of MobX was released.

Yeah, undecorate is still published manually, we will improve it eventually with #2530

Released as [email protected]

Was this page helpful?
0 / 5 - 0 ratings