bitovi / bitovi/documentjs

Type expressions for variadic functions have malformed output

Open
#217 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
598
Forks
371
PR merge metrics
No merged PRs in 30d

Description

According to [documentation for type expressions](http://documentjs.com/docs/documentjs.typeExpression.html) it should be possible to express a type annotation for a variadic function such as `{function(string, ...[number])}`.

A parameter of this form, with the straight brackets used to indicate optionality, is eventually output into documentation as a malformed `{function(string, [...)}` annotation. The closing bracket and parameter name are both missing.

There seems to be a bug in how the variadic notations are parsed when optional parameter brackets are tossed into the mix as a variadic function annotated as `{function(string, ...number)}` is correctly transformed and output as `{function(string, number...)}`

The variadic annotation `{function(...*)}` that is output as `{function(*...)}` should probably be changed to drop the asterisk though: `{function(...)}` has less noise and is, afaik, an accepted convention for functions that can take any amount of parameters of any mixed type.

---

Also, a nitpick:
The documentation incorrectly uses the term 'variable parameters'. Parameters are always variable. It's the function that may be **variadic**. (see also: [Variadic function - Wikipedia](https://en.wikipedia.org/wiki/Variadic_function))

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.