Skip to content

Support @import JSDoc tag for auto-importsΒ #62008

Open
@tobloef

Description

@tobloef

πŸ” Search Terms

"jsdoc @import", "@import auto-import", "jsdoc auto-import"

βœ… Viability Checklist

⭐ Suggestion

Since #57207 it is possible to use the JSDoc @import tag.

/** @import { Foo } from 'foo.js'; */

/** @type {Foo} */
const foo = ...;

However, auto-imports still only use the old inline syntax:

/** @type {import('foo.js').Foo} */
const foo = ...;

It would be nice to also have the option to chose the new @import syntax for the auto-imports, either by configuring an option somewhere or simply by adding another action that can be exposed in IDEs.

πŸ“ƒ Motivating Example

I believe this falls in line with the ergonomics goals outlined by the original issue about having a nicer syntax for JSDoc imports #22160.

I will not repeat the arguments made therein, but suffice to say that it produces more readable code.

πŸ’» Use Cases

Having the auto-import work with this syntax would:

  • Save time, not having to write import statements by hand.
  • Avoid mistakes due to typos, etc.
  • Help people adopt the existing feature.

(I have opened the issue here instead of over in vscode. Based on my understanding, this behavior is exposed by the TypeScript Language Server and not by the individual IDEs. Please correct me if I'm wrong.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions