Skip to content

Parameter JSDoc for a destructured parameter emits an error when a function uses arguments #51112

@phistuck

Description

@phistuck

Bug Report

When arguments is being used in a function, JSDoc @param for a destructured parameter throws an error for non existent parameter with that name.

🔎 Search Terms

jsdoc @param arguments destructured destructuring

🕗 Version & Regression Information

  • This changed between versions 4.5.5 and 4.6.2
    Around 4.6.
    The playground does not have 4.6.0 or 4.6.1, but 4.5.5 does not reproduce the issue.

⏯ Playground Link

No error - https://www.typescriptlang.org/play?ts=4.5.5&filetype=js#code/PQKhAIAEAcEMCdYFtwG8DyAjAVgUwMYAuAvuAgOYCuSuAdoQFDjNRyIqoDOh8AlreVIVqdQgDoAZr1wAbACZMWMBMjRY8RIfCo16Y-AHt6sfrngAxafMXNl7NNz4CtO0fqOETtM5dlyxjvzkvtYsrCocgc5k2iJ6hsamFlb+UcEpAEw24faotNSYZi5x4gmeSSH++TR8+JXgIMAMEpS0RLxG4HIGAMoGNIQAFkEAFEyoUn4ANOBlXj4pAFwOPEGVM2mVGcu0yLhyACK8EhJmojIAnjPVZrx1KcTEAJQMqEwJnAYyuGIyBuQjYS6QicGaTeQbVYCdbgXY0Q7HU7wc5XWEiWqVJ4AbgYxAYDFAEDsqjeYTJLFJ5PJ4LkyzSU2yVOYcwqS0ZTLQ7I5myW4HpXKZPL82z5UPIDI55JuGN51UK8AF5LxkuYyslxWBDSaLTahA6tC6vX6uCGo3GNJmLO8yT8yy4YphQvkIrh+yOJzO9Eu13Rd0qjxepI+Xx+fwBQNEoPAFtFTnS01hewRHuRXtR0r9KWxuKAA
Error - https://www.typescriptlang.org/play?ts=4.6.2&filetype=js#code/PQKhAIAEAcEMCdYFtwG8DyAjAVgUwMYAuAvuAgOYCuSuAdoQFDjNRyIqoDOh8AlreVIVqdQgDoAZr1wAbACZMWMBMjRY8RIfCo16Y-AHt6sfrngAxafMXNl7NNz4CtO0fqOETtM5dlyxjvzkvtYsrCocgc5k2iJ6hsamFlb+UcEpAEw24faotNSYZi5x4gmeSSH++TR8+JXgIMAMEpS0RLxG4HIGAMoGNIQAFkEAFEyoUn4ANOBlXj4pAFwOPEGVM2mVGcu0yLhyACK8EhJmojIAnjPVZrx1KcTEAJQMqEwJnAYyuGIyBuQjYS6QicGaTeQbVYCdbgXY0Q7HU7wc5XWEiWqVJ4AbgYxAYDFAEDsqjeYTJLFJ5PJ4LkyzSU2yVOYcwqS0ZTLQ7I5myW4HpXKZPL82z5UPIDI55JuGN51UK8AF5LxkuYyslxWBDSaLTahA6tC6vX6uCGo3GNJmLO8yT8yy4YphQvkIrh+yOJzO9Eu13Rd0qjxepI+Xx+fwBQNEoPAFtFTnS01hewRHuRXtR0r9KWxuKAA

💻 Code

/** @param {Object} argument ----- This triggers a no-such-parameter name error
    @param {string} argument.field
    @param {Object} argument.containerField
    @param {string} argument.containerField.stringField
    @param {string} argument.containerField.stringField2
    @param {number} argument.containerField.numericField */
function doSomething(
 {field, containerField: {stringField, stringField2: namedDifferently, numericField}})
{
 console.log(arguments, field, stringField, namedDifferently, numericField);
 //          ^ This is the cause
}

/** @param {
            {
             field: string,
             containerField:
              {
               stringField: string,
               stringField2: string,
               numericField: number
              }
            }
           } argument  ----- This triggers a no-such-parameter name error */
function doSomething(
 {field, containerField: {stringField, stringField2: namedDifferently, numericField}})
{
 console.log(arguments, field, stringField, namedDifferently, numericField);
 //          ^ This is the cause
}

🙁 Actual behavior

Triggers the following error -
JSDoc '@param' tag has name 'argument', but there is no parameter with that name. It would match 'arguments' if it had an array type.

🙂 Expected behavior

No error.
If an error should be thrown (but I doubt an error should be thrown), it should have a different description.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationFix AvailableA PR has been opened for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions