๐ 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