Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle correct transformation of @tracked property #4

Merged
merged 2 commits into from Dec 25, 2019

Conversation

suchitadoshi1987
Copy link
Contributor

Currently, the codemod completely replaces the classProperty node to a new node with @tracked due to which all other essential information regarding that classProperty is lost.

Eg:

import Component from "@ember/component";
import { computed, get } from "@ember/object";
import { alias } from "@ember/object/computed";

export default class Foo extends Component {
  bar;
  // baz class property
  baz = 'barBaz';

  @alias('model.isFoo')
  isFoo;

  @computed('baz', 'isFoo')
  get bazInfo() {
    return `Name: ${get(this, 'baz')}`;
  }
}

gets converted to

import { tracked } from "@glimmer/tracking";
import Component from "@ember/component";
import { computed, get } from "@ember/object";
import { alias } from "@ember/object/computed";

export default class Foo extends Component {
  bar;
  @tracked baz = "barBaz";

  @tracked isFoo;

  get bazInfo() {
    return `Name: ${get(this, "baz")}`;
  }
}

In the example above, the comment // baz class property got lost while it got converted. Also, the @alias got replaced by @tracked which is incorrect.
This PR solves both issues.

@suchitadoshi1987 suchitadoshi1987 added the bug Something isn't working label Dec 25, 2019
@suchitadoshi1987 suchitadoshi1987 merged commit 1e20073 into master Dec 25, 2019
@suchitadoshi1987 suchitadoshi1987 deleted the suchita/nonComputedDecorators branch December 25, 2019 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant