Skip to content

Support @class in JSDoc #12681

Open
Open

Description

@mjbvz

From microsoft/vscode#15168

For the following JavaScript code:

/**
 * @class
 * 
 * @param {number} x
 */
function Foo(x) {
    this.x = x
}

/**
 * @param {Foo} foo
 */
const request = function(foo) {

}

The @class jsdoc annotation for Foo does not seem to be recognized, so the type of foo in request is any:

screen shot 2016-12-05 at 3 25 07 pm

Changing the code to use class fixes the issue (you don't actually need the @class in this case):

screen shot 2016-12-05 at 3 26 45 pm

Activity

  1. added this to the milestone on Dec 15, 2016
  2. rubiesonthesky commented on Mar 10, 2024

    @rubiesonthesky

    Still can be repro'ed in playground. In VS Code, hover shows correct type.

    // @noImplicitAny: false
    // @noImplicitThis: false
    /**
     * @class
     * 
     * @param {number} x
     */
    function Foo(x) {
        this.x = x
    }
    
    /**
     * @param {Foo} foo
     */
    const request = function(foo) {
    //                       ^?
    }

    Workbench Repro

  3. typescript-bot commented on Mar 11, 2024

    @typescript-bot
    Contributor

    👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.


    Comment by rubiesonthesky

    ‼️ Exception: Error - error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. Visit https://aka.ms/ts6 for migration information.

    Error: error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
      Visit https://aka.ms/ts6 for migration information.
    
        at Object.createVirtualTypeScriptEnvironment (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:8128:11)
        at twoslasher (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:7618:17)
        at /home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:439:44
        at runTwoslashRequests (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:406:56)
        at run (/home/runner/work/_actions/microsoft/TypeScript-Twoslash-Repro-Action/master/dist/index.js:20096:75)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    

    Historical Information
    Version Reproduction Outputs Time
    5.0.2, 5.1.3, 5.2.2, 5.3.2, 5.4.2

    ⚠️ Assertions:

    • (parameter) foo: any

    ⚠️ Way slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: JSDocRelates to JSDoc parsing and type generationDomain: JavaScriptThe issue relates to JavaScript specificallyHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosHelp WantedYou can do thisSuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions