TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

[transpileDeclaration API][5.5] Self referencing generic type constraint with union gets emitted as `unknown`

Open MichaelMitchell-at opened this issue 1 year ago • 0 comments

🔎 Search Terms

transpiledeclaration type generic constraint unknown self referencing union

🕗 Version & Regression Information

5.5.0-dev.20240519

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?target=7&ts=5.5.0-dev.20240519&ssl=1&ssc=1&pln=3&pc=1#code/PTAEAEGcBcCcEsDG0Bco4FcCmAoEEATLRAGwENYzp4B7AOzU13ygAsaB3AUQFt5o8YNp179oWAgDF4JLGjIA6AguiQcgiADMZWOmR5zQi1TiwAPAA41Y0UInoxQNAEYArYrYC8oAN45QoJo0NGgAPAAqoObidASQoADKWNARAHygAD6gANoAuqkAFACUaABuNPAEoJ7pPgC+ADQ4dQDcOEA

💻 Code

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

// @filename: a.ts
export const object = {
  foo: <T extends Set<T> | []>(): void => {},
};

🙁 Actual behavior

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

export declare const object: {
    foo: <T extends unknown>() => void;
};

while when using tsc it gets emitted as

export declare const object: {
    foo: <T extends Set<T> | []>() => void;
};

🙂 Expected behavior

Using the API should emit

export declare const object: {
    foo: <T extends Set<T> | []>() => void;
};

Additional information about the issue

Weird example I know. Trust me that our actual code makes a bit more sense.

MichaelMitchell-at avatar May 21 '24 03:05 MichaelMitchell-at