Skip to content

parse-function: guide/plugin for es6 class constructors #135

@FranciscoG

Description

@FranciscoG

Support plan

  • which support plan is this issue covered by? (e.g. Community, Sponsor, or
    Enterprise): Community
  • is this issue currently blocking your project? (yes/no): no (changed to no since I figured out how to do it using plugins)
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: v13.5.0
  • module version: ^5.6.10
  • environment (e.g. node, browser, native): node
  • used with (i.e. popular names of modules): n/a
  • any other relevant information: n/a

What are you trying to achieve or the steps to reproduce?

When running app.parse on an es6 Class declaration that uses a constructor function, the results return an empty args array.

const parseFunction = require('parse-function');

const app = parseFunction(); // even passing `{ecmaVersion: 2017}` does not change the results

class MyClass {
  constructor(param1, param2) {
    this.something = param1;
    this.another = param2;
  }

  doSomething() {
    console.log(this.something);
  }
}

const result = app.parse(MyClass);
console.log(result)

What was the result you got?

{
  name: null,
  body: '',
  args: [],
  params: '',
  defaults: {},
  value: 'class MyClass {\n' +
    '  constructor(param1, param2) {\n' +
    '    this.something = param1;\n' +
    '    this.another = param2;\n' +
    '  }\n' +
    '\n' +
    '  doSomething() {\n' +
    '    console.log(this.something);\n' +
    '  }\n' +
    '}',
  isValid: true,
  isArrow: false,
  isAsync: false,
  isNamed: false,
  isAnonymous: false,
  isGenerator: false,
  

What result did you expect?

I expected args to be ['param1', 'param2']

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pkg: parse-functionPriority: LowThis issue can probably be picked up by anyone looking to contribute to the project.Status: AcceptedIt's clear what the subject of the issue is about, and what the resolution should be.Type: EnhancementMost issues will probably be for additions or changes. Expected that this will result in a PR.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions