documentationjs / documentationjs/documentation

Computed property keys side effect

Open
#1,067 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.8k
Forks
481
PR merge metrics
No merged PRs in 30d

Description

It looks like [computed property keys](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#Computed_property_names) before class declaration breaks doc parsing.

Considering this input:
```javascript
const A = 1

const B = {
[A]: 2
}

/**
* The class
*/
class C {
constructor(truite: string) {
}
}
```

Generated output misses constructor argument.

```markdown
### Table of Contents

##

The class

```

Whereas modifying B to avoid computed property key fixes the output:

```javascript
const A = 1

const B = {}
B[A] = 2

/**
* The class
*/
class C {
constructor(truite: string) {
}
}
```

Correct output returned:

```markdown

### Table of Contents

- [C][1]

## C

The class

**Parameters**

- `truite` **[string][2]**

[1]: #c

[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

```

Details:

* What version of documentation.js are you using?: **6.3.2**
* How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): **CLI**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.