Skip to content

JSDoc @import no longer works correctly with default exportsΒ #60317

Description

πŸ”Ž Search Terms

jsdoc import Import (A place for python bower components) (@import)

πŸ•— Version & Regression Information

This changed between versions 5.5.4 and 5.6.3.

⏯ Playground Link

No response

πŸ’» Code

/** @import Foo from "my-app/foo" */

/** @return {Foo} */
function getFoo() {
  return myFoo;
}

tsconfig.json excerpt:

{
 "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "my-app/*": ["src/*"]
    }
  }
}

πŸ™ Actual behavior

In TypeScript 5.5 the above worked correctly with getFoo returning Foo. As of TypeScript 5.6 this now returns an any. This workaround resolves the problem but feels like it is not what is intended.

/** @import { default as Foo } from "my-app/foo" */

/** @return {Foo} */
function getFoo() {
  return myFoo;
}

πŸ™‚ Expected behavior

I expected default exports to work with @import in JSDoc.

Additional information about the issue

No response

Activity

  1. a-tarasyuk commented on Oct 22, 2024

    @a-tarasyuk
    Contributor

    Peter Wagenet (@wagenet) Does the following test apply to your case?

    // @Filename: /tsconfig.json
    {
        "compilerOptions": {
            "allowJs": true,
            "checkJs": true,
            "baseUrl": ".",
            "paths": {
                "ns/*": ["src/*"]
            }
        }
    }
    
    // @Filename: /src/foo.ts
    export default interface Foo {
        a: number;
    }
    
    // @Filename: /src/bar.js
    /** @import Foo from "ns/foo" */
    
    /** @return {Foo} */
    function f() {
        return { a: "" };
    }
    
  2. wagenet commented on Oct 22, 2024

    @wagenet
    Author

    Oleksandr Tarasiuk (@a-tarasyuk) I have allowJs: true but no setting for checkJs.

  3. sandersn commented on Nov 22, 2024

    @sandersn
    Member

    Peter Wagenet (@wagenet) I modified Oleksandr Tarasiuk (@a-tarasyuk) 's example slightly. But it works as expected -- Foo gets imported and shows the correct error. Can you give more detail about your repro, like what the filenames are and what all your tsconfig settings are?

    I would recommend setting checkJs: true first thing because that will show errors in JS files, and there's probably an error on your @import that you're not seeing.

    // @Filename: /tsconfig.json
    {
        "compilerOptions": {
            "noEmit": true,
            "allowJs": true,
            "checkJs": true,
            "baseUrl": ".",
            "paths": {
                "ns/*": ["src/*"]
            }
        },
        "files": ["src/bar.js"]
    }
    
    // @Filename: /src/foo.ts
    export default interface Foo {
        a: number;
    }
    
    // @Filename: /src/bar.js
    /** @import Foo from "ns/foo" */
    
    /** @return {Foo} */
    function f() {
        return { a: "" };
    }
  4. ZpeedTube commented on Jun 18, 2025

    @ZpeedTube

    I have encountered the same problem with Typescript version 5.8.3 (in VS Code version 1.101.0)

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

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.Needs More InfoThe issue still hasn't been fully clarified

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions