Skip to content

Incorrect Error Message reported in JS file #15663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mjbvz opened this issue May 8, 2017 · 6 comments
Closed

Incorrect Error Message reported in JS file #15663

mjbvz opened this issue May 8, 2017 · 6 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented May 8, 2017

From @iMasoud on May 8, 2017 9:32

  • VSCode Version: 1.12.1
  • OS Version: Debian Stretch

Steps to Reproduce:

  1. Make an Empty Folder and Open it in VSCode
  2. Run npm install safejson in the same directory
  3. Add jsdoc.js File to project, open it in VSCode
  4. Paste contents of attached text file in it
    jsdoc.txt

I honestly don't know if this is a problem with VSCode or JSDoc or Mentioned Module, but I do care about VSCode, so I'm reporting this.

Here is the Result:
jsdoc

As you can see VSCode shows this error as a problem in my code:
Supplied parameters do not match any signature of call target.
I was following module guide (and the code was running well) so I took a look at the module code. Following is the method that I was calling from that module:
safejson
(Whole file is available in here: https://github.com/evanshortiss/safejson/blob/848fcc7d8273f99fa783d2f27e2f57d2cc581a7c/src/index.js)

As you can see JSDoc documents/comments in module look fine. So, as I said before, I'm not really sure if this is a problem with VSCode. I'll be glad to read your opinions about this.

Regards

Copied from original issue: microsoft/vscode#26196

@mjbvz mjbvz self-assigned this May 8, 2017
@mjbvz mjbvz removed their assignment May 8, 2017
@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label May 8, 2017
@mjbvz
Copy link
Contributor Author

mjbvz commented May 8, 2017

The root cause here seems to be the commented out argument names in safejson. This causes the signature or parse to be function(): void

@mhegazy mhegazy added the Bug A bug in TypeScript label May 8, 2017
@mhegazy
Copy link
Contributor

mhegazy commented May 8, 2017

We only look for arguments in jsdoc if they are defined, we should be more graceful.

@mhegazy
Copy link
Contributor

mhegazy commented May 10, 2017

Based on the discussion from #15747, the function implementation should hold the truth about the signature, we only use the JSDoc for types.
so in the issue above, the function uses arguments so it should have a signature of .(..args: any[]): void

@iMasoud
Copy link

iMasoud commented May 11, 2017

I want to know if I'm getting this right:
As an standard function that accepts variable count of parameters should have proper JSDoc documents to tell this, this is a problem with documents of mentioned method not VSCode. If I'm right, is this how you are suggesting that method and it's documents should be?

/**
 * Parse string of JSON and catch any possible exceptions.
 * @param {String} json
 * @param {...Function} functions reviever & callback or callback only
 */
exports.parse = function()
{
    /* function body */
};

@mhegazy
Copy link
Contributor

mhegazy commented May 11, 2017

parse in safejson is documented correctly as per JSDoc. the second parameter is optional, that means you can call parse(json, callback) or parse(json, receiver, callback). TS does not support having optional parameters in the middle of the argument list, but that is not the issue.

the real issue is that the compiler looks at the function body, finds no arguments function(), so it can not reconcile the function with the jsdoc.

The proposed fix is to always use the function even if it does not match the jsdoc.

@rbuckton rbuckton added the Fixed A PR has been merged for this issue label Jun 22, 2017
@rbuckton
Copy link
Member

Fixed, pending PR.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

4 participants