Skip to content

JavaScript argument with default value is output twice #233

@roadhump

Description

@roadhump

It looks like a bug in any output format when using default argument value in JavaScript

/**
 * Number
 *
 * @param {number} x an argument
 *
 * @returns {number} some
 */
export const myfunc = (x = 123) => x;

output html
screenshot 2015-11-08 20 08 14

output JSON

[
  {
    "description": "Number",
    "tags": [
      {
        "title": "param",
        "description": "an argument",
        "lineNumber": 3,
        "type": {
          "type": "NameExpression",
          "name": "number"
        },
        "name": "x"
      },
      {
        "title": "returns",
        "description": "some",
        "lineNumber": 5,
        "type": {
          "type": "NameExpression",
          "name": "number"
        }
      }
    ],
    "loc": {
      "start": {
        "line": 1,
        "column": 0
      },
      "end": {
        "line": 7,
        "column": 3
      }
    },
    "context": {
      "loc": {
        "start": {
          "line": 8,
          "column": 0
        },
        "end": {
          "line": 8,
          "column": 30
        }
      },
      "file": "/Users/roadhump/Projects/CustomFieldConstraints/src/shared/services/test.js",
      "code": "/**\n * Number\n *\n * @param {number} x an argument\n *\n * @returns {number} some\n */\nexport default (x = 123) => x;\n"
    },
    "params": [
      {
        "title": "param",
        "description": "an argument",
        "lineNumber": 3,
        "type": {
          "type": "NameExpression",
          "name": "number"
        },
        "name": "x"
      },
      {
        "title": "param",
        "name": "x",
        "default": "123"
      }
    ],
    "returns": [
      {
        "title": "returns",
        "description": "some",
        "lineNumber": 5,
        "type": {
          "type": "NameExpression",
          "name": "number"
        }
      }
    ],
    "name": "x",
    "kind": "function",
    "members": {
      "instance": [],
      "static": []
    },
    "path": [
      "x"
    ]
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions