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] Self referencing generic type constraint with union gets emitted as unknown #58598

Closed
MichaelMitchell-at opened this issue May 21, 2024 · 0 comments Β· Fixed by #58610
Labels
Bug A bug in TypeScript Domain: Isolated Declarations Related to the --isolatedDeclarations compiler flag Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it

Comments

@MichaelMitchell-at
Copy link

MichaelMitchell-at commented May 21, 2024

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

@weswigham weswigham added Bug A bug in TypeScript Domain: ts.transpileDeclaration Issues regarding the transpileDeclaration API, which do not reproduce without it Domain: Isolated Declarations Related to the --isolatedDeclarations compiler flag labels May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Isolated Declarations Related to the --isolatedDeclarations compiler flag 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.

2 participants