Skip to content

Error when encountering ArrowFunctionExpression in computed setter #424

Description

@xg-wang

For example:

  _list: computed('list.[]', {
    get() {
      return A(get(this, 'list').map((el) => el));
    },
    set: (key, value) => value
  }),

This code will throw

Transformation error (Cannot read property 'map' of undefined)
TypeError: Cannot read property 'map' of undefined
at Lines.Lp.join (~/.npm/_npx/41642/lib/node_modules/ember-native-class-codemod/node_modules/jscodeshift/node_modules/recast/lib/lines.js:867:12)

Chatted with @rwjblue, arrow function should be forbidden in computed properties: https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-arrow-function-computed-properties.md

The codemod should check ArrowFunctionExpression and throw a more meaningful error on this specific file

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions