Skip to content

[transpileDeclaration API][5.5] More missing type-only importsΒ #58511

Closed
@MichaelMitchell-at

Description

@MichaelMitchell-at

πŸ”Ž Search Terms

transpiledeclaration api emit missing import

πŸ•— Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?target=7&ts=5.5.0-dev.20240512#code/PTAEAEGcBcCcEsDG0Bco4FcCmAoEEATLRAGwENYzp4B7AOzU13ygAsaB3AUQFt5o8YNp179oWAgDF4JLGjIA6AguiRBESO259o4qTLmgARkpVr14AGYG6ZHocWqcWAB4AHGrGih4dcbEsyRCxQAEk6UABvHFBQAG0AaywATzQYBDoAcwBdNAw6BLpOOgBuHABfZ3dPb19-QODQAHkMb2jYxJS0uF8cvIKijlKKqo8vdGS3EIAhMkgQgF5QAHIyZdAAHxWjZbKLa1lbezQTJ3geMbaJqbC6ABprkJboB+hJmbmQ8tBLWBoeUAAIgUwDIgL2rkuoEQ9BgoBoRgAVsRvEt2qACDQACqsXoAHixoFc4joBEgoFm8wAfAAKAD6qFAWIedN8aHCcSx2QAlGhnpzslEYrFQLAsNAMLBhrFyncKmUgA

πŸ’» Code

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

// @filename: a.ts
export interface In {
  [key: string]: unknown;
}
export interface Out {
  [key: string]: unknown;
}
export type Base = 'a' | 'b';

// @filename: b.ts
import { type In, type Out, type Base } from "./a";

export const object = {
  doThing<T extends Base>(_t: T, _in: In[T]): Out[T] {
    return;
  },
};

πŸ™ Actual behavior

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

import { type In } from "./a";
export declare const object: {
    doThing<T extends Base>(_t: T, _in: In[T]): Out;
};

while when using tsc it gets emitted as

import { type In, type Out, type Base } from "./a";
export declare const object: {
    doThing<T extends Base>(_t: T, _in: In[T]): Out[T];
};

(interestingly the Debug tab of the workbench link shows something that's partially wrong)

πŸ™‚ Expected behavior

Using the API should emit

import { type In, type Out, type Base } from "./a";
export declare const object: {
    doThing<T extends Base>(_t: T, _in: In[T]): Out[T];
};

Additional information about the issue

No response

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