Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

TypeError: this[statement.type] is not a function #199

Closed
dividedmind opened this issue Mar 1, 2023 · 2 comments · Fixed by #201
Closed

TypeError: this[statement.type] is not a function #199

dividedmind opened this issue Mar 1, 2023 · 2 comments · Fixed by #201
Assignees
Labels
bug Something isn't working released

Comments

@dividedmind
Copy link
Contributor

I got the following error trying to map @appland/models as of a41b670ae170303cc46f74a2d6afb535eaa9dbd9:

FAIL  tests/unit/appMapFilter.spec.js
  ● Test suite failed to run

    TypeError: this[statement.type] is not a function

      at Object.BlockStatement (file:/home/divide/projects/appmap-js/node_modules/astring/dist/astring.mjs:286:29)
      at Object.ClassDeclaration (file:/home/divide/projects/appmap-js/node_modules/astring/dist/astring.mjs:529:10)
      at Object.Program (file:/home/divide/projects/appmap-js/node_modules/astring/dist/astring.mjs:261:27)
      at generate (file:/home/divide/projects/appmap-js/node_modules/astring/dist/astring.mjs:1178:29)
      at instrument$2 (file:/home/divide/projects/appmap-js/node_modules/@appland/appmap-agent-js/dist/bundles/transformer-jest.mjs:2726:18)
      at instrument$1 (file:/home/divide/projects/appmap-js/node_modules/@appland/appmap-agent-js/dist/bundles/transformer-jest.mjs:2808:37)
      at instrument (file:/home/divide/projects/appmap-js/node_modules/@appland/appmap-agent-js/dist/bundles/transformer-jest.mjs:3089:55)
      at transform (file:/home/divide/projects/appmap-js/node_modules/@appland/appmap-agent-js/dist/bundles/transformer-jest.mjs:3176:13)
      at processAsync (file:/home/divide/projects/appmap-js/node_modules/@appland/appmap-agent-js/dist/bundles/transformer-jest.mjs:3239:16)
      at ScriptTransformer.transformSourceAsync (../../node_modules/@jest/transform/build/ScriptTransformer.js:676:25)
@dividedmind dividedmind self-assigned this Mar 3, 2023
@dividedmind dividedmind added the bug Something isn't working label Mar 3, 2023
@dividedmind
Copy link
Contributor Author

I tracked it down to @babel/parser emitting ClassProperty instead of the standard PropertyDefinition. It seems its estree plugin is misconfigured; investigating.

dividedmind added a commit that referenced this issue Mar 3, 2023
appmap-agent-js uses @babel/parser to parse the ECMAScript code for
transformation; the output generated by that library is not 100%
estree-compliant [1]. It has an `estree` plugin that reverts the
deviations; however, by default not all of them are supported
(apparently for @babel/parser's own backward compatibility reasons).
Fortunately it has a config setting that enables them.

One of these differences is that the standard node type of
PropertyDefinition is called ClassProperty instead, which made the
transformer unable to correctly handle ES classes.

[1] https://babeljs.io/docs/babel-parser#output

Fixes #199
dividedmind added a commit that referenced this issue Mar 3, 2023
appmap-agent-js uses @babel/parser to parse the ECMAScript code for
transformation; the output generated by that library is not 100%
estree-compliant [1]. It has an `estree` plugin that reverts the
deviations; however, by default not all of them are supported
(apparently for @babel/parser's own backward compatibility reasons).
Fortunately it has a config setting that enables them.

One of these differences is that the standard node type of
PropertyDefinition is called ClassProperty instead, which made the
transformer unable to correctly handle ES classes.

[1] https://babeljs.io/docs/babel-parser#output

Fixes #199
dividedmind added a commit that referenced this issue Mar 3, 2023
appmap-agent-js uses @babel/parser to parse the ECMAScript code for
transformation; the output generated by that library is not 100%
estree-compliant [1]. It has an `estree` plugin that reverts the
deviations; however, by default not all of them are supported
(apparently for @babel/parser's own backward compatibility reasons).
Fortunately it has a config setting that enables them.

One of these differences is that the standard node type of
PropertyDefinition is called ClassProperty instead, which made the
transformer unable to correctly handle ES classes.

[1] https://babeljs.io/docs/babel-parser#output

Fixes #199
dividedmind added a commit that referenced this issue Mar 3, 2023
appmap-agent-js uses @babel/parser to parse the ECMAScript code for
transformation; the output generated by that library is not 100%
estree-compliant [1]. It has an `estree` plugin that reverts the
deviations; however, by default not all of them are supported
(apparently for @babel/parser's own backward compatibility reasons).
Fortunately it has a config setting that enables them.

One of these differences is that the standard node type of
PropertyDefinition is called ClassProperty instead, which made the
transformer unable to correctly handle ES classes.

[1] https://babeljs.io/docs/babel-parser#output

Fixes #199
appland-release pushed a commit that referenced this issue Mar 3, 2023
## [13.5.2](v13.5.1...v13.5.2) (2023-03-03)

### Bug Fixes

* Support class features when transforming source code ([46f03b0](46f03b0)), closes [#199](#199)
@appland-release
Copy link

🎉 This issue has been resolved in version 13.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants