Skip to content

Type variable leak and odd errorΒ #61667

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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