microsoft / microsoft/TypeScript

JSDoc `@import` no longer works correctly with default exports

Open
#60,317 4 comments 2 reactions 1 assignee View on GitHub

@sandersn is already working on this.

Since Nov 8, 2024.

Needs Investigation Needs More Info
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 Search Terms

jsdoc import @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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.