Closed
Description
π Search Terms
transpile declaration api emit missing import
π Version & Regression Information
- This changed in commit or PR Add
transpileDeclaration
API methodΒ #58261 @weswigham
β― 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 => {};
π 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;