Skip to content

nested generic function inference causes unbound type parameter leakΒ #55467

Closed
@tjjfvi

Description

@tjjfvi

πŸ”Ž Search Terms

unbound generic, unbound type parameter

πŸ•— Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ.

⏯ Playground Link

https://www.typescriptlang.org/play?jsx=0#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwHcYoAHAHgA0A+ACgA8AueCgSiYG95Hn4BfAKFCRYCFOmx54YKBAhkAgvBB0MIVMADO8KKgCeAbQC6AGngAVWt07caAOnuwA5hqbyW8ALxVzfU-dtOLvBuTGb8-GB4GhjwECBQANaeUjIQNESkNGQW9KHuXlwspgCMLPwA9OXw1fAAegD8-EA

πŸ’» Code

declare function wrap<X>(x: X): { x: X }
declare function call<A extends any[], T>(x: { x: (...args: A) => T }, ...args: A): T

const leak = call(wrap(<T>(x: T) => x), 1)
//    ^? - const leak: A[0]

πŸ™ Actual behavior

The type of leak involves an unbound type parameter.

πŸ™‚ Expected behavior

The type of leak should be number.

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions