Closed
Description
Search terms
- VarArgs inference
- javascript files
Expected Behavior
- To use the
@params
to document the method and not infer an VarArgs.
Actual Behavior
- Actually, it's not what Typedoc failed to do, it's what it actually did.
When usingarguments
in a JavaScript function, Typedoc infers VarArgs onto the end of the method even when an actual argument has not been used, e.g., usingarguments.length
as opposed to an actual argumentarguments[1]
. This appears to be a Typedoc issue since using the TypeScript playground indicates that the method has only one argument of typeany
as expected and correctly didn't apply VarArgs per this statement in the TypeScript documentation. What appears to be at issue with the documentation generated by Typedoc is that any reference toarguments
will assume themethod/function
has, ...args: any[]
rather than strictly only when an reference to an actual argument is made, e.g.,arguments[1]
.
Steps to reproduce the bug
typedoc.json
{
"entryPoints": ["test-class.js"],
"out": "docs"
}
tsconfig.js
{
"compilerOptions": {
"target": "es2020",
"module": "es2020",
"allowJs": true,
"checkJs": true,
"outDir": "./dist",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
test-class.js
/**
* This is a test class.
*/
export class test
{
constructor ( )
{
if ( this.constructor === test )
throw new TypeError( `class is not constructable` ) ;
return this ;
}
/**
* Determines whether a type instance is an instance of this class.
* @remarks
* Some remarks...
* @param {any} type
* The instance used.
* @returns {boolean}
* |What|Description|
* |:---|:----------|
* |`True` |When the instance is of type test class.|
* |`False`|When the instance is not of type test class.|
* |`TypeError`|When not enough or extraneous arguments were given.|
*/
static [ Symbol.hasInstance ] ( type )
{
const meth = this[ Symbol.hasInstance ] ;
const args = meth.length ;
if ( arguments.length < args )
throw new TypeError( `too few arguments specified` ) ;
if ( arguments.length > args )
throw new TypeError( `too many arguments specified` ) ;
return type !== null && type !== undefined && type.constructor === test ;
}
}
Environment
- Typedoc version: 0.21.2
- TypeScript version: 4.3.4
- Node.js version: 12.22.1
- OS: Windows 7 [which is why I'm limited to node 12.22.1]