Skip to content

[transpileDeclaration API][5.5] Type-only import is missing when type is used as arrow function argumentΒ #58430

Closed
@MichaelMitchell-at

Description

@MichaelMitchell-at

πŸ”Ž Search Terms

transpile declaration api emit missing import

πŸ•— Version & Regression Information

⏯ Playground Link

https://github.com/MichaelMitchell-at/transpile_declaration_bug_repro/tree/bug2

πŸ’» Code

// @strict: true
// @declaration: true
// @showEmit
// @showEmittedFile: a.d.ts
// @showEmittedFile: b.d.ts

// @filename: a.ts
export interface Type {}

// @filename: b.ts
import { type Type } from "./a";

export const foo = (_: Type): void => {};
export const bar = (_: import("./a").Type): void => {};

Workbench Repro

πŸ™ Actual behavior

Refer to this program which invokes the ts.transpileDeclaration API:
https://github.com/MichaelMitchell-at/transpile_declaration_bug_repro/blob/bug2/transpile.mjs

Basic instructions to invoke it can be found in
https://github.com/MichaelMitchell-at/transpile_declaration_bug_repro/blob/bug2/README.md

When using the API, b.d.ts is emitted as

export declare const foo: (_: Type) => void;
export declare const bar: (_: any) => void;

while when using tsc it gets emitted as

import { type Type } from "./a";
export declare const foo: (_: Type) => void;
export declare const bar: (_: import("./a").Type) => void;

πŸ™‚ Expected behavior

Using the API should emit

import { type Type } from "./a";
export declare const foo: (_: Type) => void;
export declare const bar: (_: import("./a").Type) => void;

Additional information about the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: ts.transpileDeclarationIssues regarding the transpileDeclaration API, which do not reproduce without it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions