typedoc-plugin-markdown icon indicating copy to clipboard operation
typedoc-plugin-markdown copied to clipboard

Potential bug with optional function argument

Open Zamiell opened this issue 2 years ago • 2 comments

Hello, I think I found a bug in the plugin.

Here's the source code for a function called "spawnCustomGridEntity": https://github.com/IsaacScript/isaacscript/blob/4d4cfd0/packages/isaacscript-common/src/classes/features/callbackLogic/CustomGridEntities.ts#L229-L237

We can see that it has, in order:

  • 2 mandatory arguments
  • 3 optional arguments
  • 2 more optional arguments, with a default value specified

TypeDoc makes the output of the function look like this: https://isaacscript.github.io/isaacscript-common/features/CustomGridEntities#parameters

We can see that the final two arguments do not have the question mark like the other optional arguments do, which seems to be a bug.

Zamiell avatar Feb 08 '23 22:02 Zamiell

Interesting - we can easily flag default params as optional (which technically they are), but what if the first argument has a default value.? In this case you would have to pass in null or undefined to the first argument.

tgreyuk avatar Feb 08 '23 23:02 tgreyuk

That's true. So perhaps the plugin should only mark arguments as being "optional" if they are not followed by a mandatory argument.

Zamiell avatar Feb 08 '23 23:02 Zamiell

[email protected]

tgreyuk avatar May 03 '24 19:05 tgreyuk