ember-native-class-codemod icon indicating copy to clipboard operation
ember-native-class-codemod copied to clipboard

Does not match field "body"

Open MichalBryxi opened this issue 5 years ago • 0 comments

Given this code snippet:

import Service from '@ember/service';
import { computed } from '@ember/object';

export default Service.extend({
  strategies: computed(() => []), // offending line
});

I will get following error output:

...
Sending 1 files to free worker...
 ERR ./addon/services/global-search.js Transformation error ([] does not match field "body": [MethodDefinition | VariableDeclarator | ClassPropertyDefinition | ClassProperty | ClassMethod | TSDeclareMethod | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSIndexSignature | TSMethodSignature | TSPropertySignature] of type ClassBody)
Error: [] does not match field "body": [MethodDefinition | VariableDeclarator | ClassPropertyDefinition | ClassProperty | ClassMethod | TSDeclareMethod | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSIndexSignature | TSMethodSignature | TSPropertySignature] of type ClassBody
    at addParam (/Users/mbryxi/ember/ember-native-class-codemod/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:565:23)
    at /Users/mbryxi/ember/ember-native-class-codemod/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:594:21
    at Array.forEach (<anonymous>)
    at Function.builder [as classBody] (/Users/mbryxi/ember/ember-native-class-codemod/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:592:30)
    at classBody (/Users/mbryxi/ember/ember-native-class-codemod/transforms/helpers/transform-helper.js:402:9)
    at NodePath.createClass (/Users/mbryxi/ember/ember-native-class-codemod/transforms/helpers/parse-helper.js:229:33)
    at /Users/mbryxi/ember/ember-native-class-codemod/node_modules/jscodeshift/src/Collection.js:77:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/mbryxi/ember/ember-native-class-codemod/node_modules/jscodeshift/src/Collection.js:76:18)
    at forEach (/Users/mbryxi/ember/ember-native-class-codemod/transforms/helpers/parse-helper.js:200:42)
All done.
Results:
1 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 1.931seconds

For my test I had to used own patched version of ember-native-class-codemod that has patched version of ember-codemods-telemetry-helpers to mitigate other error that is described in #314

MichalBryxi avatar Jul 20 '20 16:07 MichalBryxi