Skip to content

JSdoc 'import type' syntax wrongly transformed when generate declaration from js file #46575

Closed
@xlfsummer

Description

@xlfsummer

Bug Report

🔎 Search Terms

Import type syntax error after generate .d.ts from js
Import type error after generate .d.ts using JSdoc

🕗 Version & Regression Information

💻 Code

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

demo repo (using 'import-types' branch, not 'master')

🙁 Actual behavior

output index.d.ts

/** @type {import('./type').Foo} */
export const foo: import('./type').Foo;

import is a method for loading async resource in js/ts, not import a type. it should be transformed to import .. from .. .

🙂 Expected behavior

output index.d.ts

import {Foo} from './type';
/** @type {import('./type').Foo} */
export const foo: Foo;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions