Skip to content

Type variable leak and odd error#61667

@ahejlsberg

Description

@ahejlsberg

🔎 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

declarefunctioncall<A,R>(obj: {x: (a: A)=>R},arg: A): Rdeclarefunctionwrap<X>(x: X): {x: X}declarefunctionid<T>(x: T): T;constleak1=call(wrap(id),1)// Type variable leak and odd errorconstleak2=call(wrap(id),1asany)// 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

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions