Skip to content

Unexpected parameter hint showing up for log in js file  #33565

Description

@mjbvz

From microsoft/vscode#80565

TypeScript Version: 3.7.20190922

Search Terms:

  • javascript
  • parameter hints / signature help

Code
In a js file:

//@ts-check

log(

Trigger parameter hints on log

Expected behavior:
Nothing shows up. log is undefined here and you can't run go to definition on it

Actual behavior:
Screen Shot 2019-09-23 at 11 59 10 AM

Playground Link:

Related Issues:

Activity

  1. RyanCavanaugh commented on Sep 25, 2019

    @RyanCavanaugh
    Member

    wat

  2. a-tarasyuk commented on Jan 28, 2020

    @a-tarasyuk
    Contributor

    I investigated the issue, and this error happens because

    return name === undefined ? undefined : firstDefined(program.getSourceFiles(), sourceFile =>

    returns es5.d.ts source file and

    firstDefined(sourceFile.getNamedDeclarations().get(name), declaration => {

    returns sourceFile.getNamedDeclarations() all declarations and ignore namespaces. For instance log it is a name from Math object :).

    Is there any reason why sourceFile.getNamedDeclarations() is used here?

    cc Daniel Rosenwasser (@DanielRosenwasser) Ryan Cavanaugh (@RyanCavanaugh)

  3. DanielRosenwasser commented on Jan 28, 2020

    @DanielRosenwasser
    Member

    I think the idea is to try a best-effort signature help given that we're in JavaScript and we won't always have accurate types around.

    If you're in ts-check, this behavior is probably extremely surprising because you're also getting an error that the identifier can't be found. Maybe the solution is to turn it off just there.

  4. a-tarasyuk commented on Jan 29, 2020

    @a-tarasyuk
    Contributor

    Daniel Rosenwasser (@DanielRosenwasser) Do you mean disable/remove createJSSignatureHelpItems?

  5. DanielRosenwasser commented on Jan 29, 2020

    @DanielRosenwasser
    Member

    Yeah, if

    • the current file belongs to a tsconfig.json
    • the current file is checked
    • the current file belongs to a project with checkJs

    I think we should probably disable the heuristic. Does that sound reasonable?

  6. a-tarasyuk commented on Jan 31, 2020

    @a-tarasyuk
    Contributor

    Daniel Rosenwasser (@DanielRosenwasser) It seems in this case, users who use JavaScript without TS checks will get weird suggestions. Or am I wrong?

    const candidateInfo = getCandidateOrTypeInfo(argumentInfo, typeChecker, sourceFile, startingToken, onlyUseSyntacticOwners);

    Returns correct info for global functions (parseInt, eval, etc), or Objects (Math.log, Date etc). I'm trying to understand where this heuristic can help 😃 👀

  7. mjbvz commented on Feb 1, 2020

    @mjbvz
    Author

    Would it be ok to only return signature help when we can properly resolve a symbol? This is what we do for quickInfo for example.

    The majority of VS Code users are on untyped JS so I’m wary of a fix that is specific to checkJs

  8. a-tarasyuk commented on Apr 10, 2020

    @a-tarasyuk
    Contributor

    createJSSignatureHelpItems was added in this PR #2641, and changed in this #26025. Both PRs don't have tests - and it is difficult to understand which cases these changes cover, however, without createJSSignatureHelpItems tests work fine.

  9. DanielRosenwasser commented on Apr 14, 2020

    @DanielRosenwasser
    Member

    My personal take is that in a checked JS file, or in a TypeScript project, we should not apply the heuristic. Otherwise, I think the heuristic is fine.

  10. DanielRosenwasser commented on Apr 14, 2020

    @DanielRosenwasser
    Member

    Ah, I just looked up and saw that reread the convo.

    Uh, maybe this is something we should try to understand better - would it be easy to conduct a user study on this? Let's chat about this tomorrow Matt Bierner (@mjbvz)

  11. mjbvz commented on Apr 14, 2020

    @mjbvz
    Author

    Sure. I'm still of the opinion that the behavior of parameter hints should match hover. It seems confusing to show parameter hints on symbols that we can't resolve

  12. RyanCavanaugh commented on Apr 15, 2020

    @RyanCavanaugh
    Member

    Notes from meeting today:

    • Disable this behavior entirely for bare identifiers
    • Add some description of which declaration the description is coming from
  13. a-tarasyuk commented on Apr 16, 2020

    @a-tarasyuk
    Contributor

    Ryan Cavanaugh (@RyanCavanaugh) Thanks for the update.

    What does mean bare identifiers? 😕

    Add some description of which declaration the description is coming from

    Do you mean to add an additional field to the server response?

  14. DanielRosenwasser commented on Apr 17, 2020

    @DanielRosenwasser
    Member

    Oleksandr Tarasiuk (@a-tarasyuk) Ryan can comment on the second part.

    To answer your first question, the idea is foo should not try to search for members named foo anywhere, but foo.bar should still look for declarations named bar. That seems fairly reasonable to me.

  15. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: LS: Quick Infoe.g. hover text, tool-tips, and tooltips.Domain: LS: Signature HelpInformation in editor tooltips when invoking a function call

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions