Skip to content

[transpileDeclaration API][5.5] Incorrectly creates new alias for generic parameter #58512

Closed

Description

🔎 Search Terms

transpiledeclaration api alias generic parameter name

🕗 Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?target=7&ts=5.5.0-dev.20240512#code/PTAEAEGcBcCcEsDG0Bco4FcCmAoEEATLRAGwENYzp4B7AOzU13ygAsaB3AUQFt5o8YNp179oWAgDF4JLGjIA6AguiRBESO259o4qTLmgARkpVr14AGYG6ZHocWqcWAB4AHGrGjoAnm6ygAErEngQAPADSWD6gruJ0BJCgMAh0AOYANKAAamQk2AB8oAC8oADeOKCgANoRoPB0oFE+ALpouflYANw4AL49FtaytvZoJk7wPB5e5UEhsASgvaCWsDQ8oABECsBkmz2u097QfgGSNDSRsS7xiclwDWlFpcGIoZFZdBg8RliwBQNDp5vG86DBQDQjAArErlSqgAg0AAqrEeVziWASSRSjwKAAoAPoAazQEQAlGhzpcIkUKlUqrAsNAMLBGmVlmQkmQ6D4elVehk+j0gA

💻 Code

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

// @filename: a.ts
export type Record<Key extends string, Value> = {
  [K in Key]: Value;
};

// @filename: b.ts
import { Record } from "./a";
export type Foo<K extends string> = Record<K, number>;

export const obj = {
  doThing<K extends string>(_k: K): Foo<K> {
    return {} as any;
  },
};

🙁 Actual behavior

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

import { Record } from "./a";
export type Foo<K extends string> = Record<K, number>;
export declare const obj: {
    doThing<K extends string>(_k: K): Record<K_1, number>;
};

while when using tsc it gets emitted as

import { Record } from "./a";
export type Foo<K extends string> = Record<K, number>;
export declare const obj: {
    doThing<K extends string>(_k: K): Foo<K>;
};

🙂 Expected behavior

Using the API should emit

import { Record } from "./a";
export type Foo<K extends string> = Record<K, number>;
export declare const obj: {
    doThing<K extends string>(_k: K): Foo<K>;
};

Additional information about the issue

No response

Activity

  1. added
    Bug
    Domain: Declaration Emit
    on May 13, 2024
  2. added
    Domain: API: ts.transpileDeclaration
    on May 14, 2024
  3. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDomain: API: ts.transpileDeclarationDomain: Declaration Emit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions