[transpileDeclaration API][5.5] Incorrectly creates new alias for generic parameter
MichaelMitchell-at opened this issue Β· comments
michaelm commented
π Search Terms
transpiledeclaration api alias generic parameter name
π Version & Regression Information
- This changed in commit or PR #58261 @weswigham
β― Playground Link
π» 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