Skip to content

Go-to-definition in JSDoc tag followed by diagnostics request incorrectly creates new errors #50341

Description

declare class Stuff {
    /** For more thorough tests, use {@link checkBarIs} */
    checkFooLengthIs(len: number): void;

    checkFooIs(value: object): void;
}

Currently, this .ts file produces no errors.

However, if you very-quickly replace checkBarIs with checkFooIs in the above example by double-clicking and pasting in the new text, then VS Code will sometimes then make a definitionAndBoundSpan request. That request will get served, and then the editor will request errors. The errors returned then become nonsensical.

Expected: No errors
Actual:

  • Line 2:45-55 - "Cannot find name 'checkFooIs'. Did you mean the instance member 'this.checkFooIs'?"
  • Line 3:5-21 - "Cannot find name 'checkFooIs'."

Here's a GIF of this in action

jsdocFastTypingInLinkTag


Here's a relevant fourslash test that currently fails.

/// <reference path="./fourslash.ts" />

////declare class Stuff {
////    /** For more thorough tests, use {@link [|checkFooIs|]} */
////    checkFooLengthIs(len: number): void;
////
////    /*checkFooIsDef*/checkFooIs(value: object): void;
////}

const range = test.ranges()[0];
goTo.selectRange(range);
verify.goToDefinitionIs("checkFooIsDef");
verify.noErrors();

Activity

  1. changed the title [-]Sequentially editing `@link` content, running go-to-definition, then diagnostics, incorrectly creates new errors[/-] [+]Go-to-definition in `@link` tag followed by diagnostics request incorrectly creates new errors[/+] on Aug 17, 2022
  2. DanielRosenwasser commented on Aug 17, 2022

    @DanielRosenwasser
    MemberAuthor

    Unfortunately this isn't related to the @link tag - I think it occurs in any JSDoc that might try to resolve.

    /**
     * @param asd {[|UnresolvedTypeReference|]}
     */
    function blah(asd) {
    }

    If you do the same sort thing - run a semantic operation on UnresolvedTypeReference, and then request errors - then you'll start seeing errors in the JSDoc, even in a .ts file.

    image

  3. changed the title [-]Go-to-definition in `@link` tag followed by diagnostics request incorrectly creates new errors[/-] [+]Go-to-definition in JSDoc tag followed by diagnostics request incorrectly creates new errors[/+] on Aug 17, 2022
  4. DanielRosenwasser commented on Aug 17, 2022

    @DanielRosenwasser
    MemberAuthor

    #49109 seems strongly related.

  5. DanielRosenwasser commented on Oct 6, 2022

    @DanielRosenwasser
    MemberAuthor

    Another

    /**
     * @type {{ x: $ }}
     */

    Type in this[""] and you'll get the error:

    A 'this' type is available only in a non-static member of a class or interface.
    
  6. added a commit that references this issue on May 8, 2023
    20e4b70
  7. locked as resolved and limited conversation to collaborators on Oct 22, 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 TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions