Skip to content

Type variable leak and odd error #61667

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

Open
ahejlsberg opened this issue May 7, 2025 · 0 comments Β· May be fixed by #61668
Open

Type variable leak and odd error #61667

ahejlsberg opened this issue May 7, 2025 · 0 comments Β· May be fixed by #61668
Assignees
Labels
Bug A bug in TypeScript

Comments

@ahejlsberg
Copy link
Member

ahejlsberg commented May 7, 2025

πŸ”Ž Search Terms

type variable leak

πŸ•— Version & Regression Information

This is the behavior in 5.8.3 and nightly build

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXzCgggB4BBAGngCUA+AChwCMArALngG94APD+qBzIBKeAF5aNeAF8qsAOZDhHagChQkWAhTpseeAHcYUAA4kAGgz7xzyrrw7mZ68NDhI0mXPizASAFSsOfzt-AG5VVTA8AGcMeAgQKABrAEZxAiIIeiNTel9hKlTRAHoS+H8ATxMEADdYLCgmRISk5PgoVGB4HGBukBgYHBgo2PjElIAmDMJiHOMTfOBC+HSoGI7UStLyqpr4ephG5oQJ5NUgA

πŸ’» Code

declare function call<A, R>(obj: { x: (a: A) => R }, arg: A): R
declare function wrap<X>(x: X): { x: X }
declare function id<T>(x: T): T;

const leak1 = call(wrap(id), 1) // Type variable leak and odd error
const leak2 = call(wrap(id), 1 as any) // Type variable leak

πŸ™ Actual behavior

The type of the two variables is A, a leaked type variable.

πŸ™‚ Expected behavior

No leaks.

Additional information about the issue

No response

@ahejlsberg ahejlsberg self-assigned this May 7, 2025
@ahejlsberg ahejlsberg added the Bug A bug in TypeScript label May 7, 2025
@ahejlsberg ahejlsberg linked a pull request May 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant