Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MichaelMitchell-at opened this issue May 4, 2024 · 3 comments Β· Fixed by #58475
Labels
Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it

Comments

@MichaelMitchell-at
Copy link

MichaelMitchell-at commented May 4, 2024

πŸ”Ž 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

@MichaelMitchell-at MichaelMitchell-at changed the title [transpileDeclaration API][5.5] [transpileDeclaration API][5.5] Type-only import is missing when type is used as arrow function argument May 4, 2024
@robpalme
Copy link

robpalme commented May 4, 2024

The bug description seems to have a typo because the Actual vs Expected code snippets are identical.

@fatcerberus
Copy link

I'm guessing the tsc and API output are mistakenly swapped under Actual Behavior.

@MichaelMitchell-at
Copy link
Author

The bug description seems to have a typo because the Actual vs Expected code snippets are identical.

Corrected, thanks

@weswigham weswigham added the Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants