Closed
Description
Bug Report
π Search Terms
unbound type parameter generic leak
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ
β― Playground Link
π» Code
// @declaration
export const obj = <A,>(shape: { [K in keyof A]: A[K] }) => shape
// .d.ts shows correct type
export const box = <B,>(t: B) => obj({ value: t });
// ^?
// Type looks correct
// .d.ts shows const x: { value: B }
export const x = box(5)
// ^?
// Shows unbound B
// .d.ts shows const x: { value: B }
export const y = x
// ^?
// Shows unbound B
// .d.ts shows type U = typeof x.value
export type U = typeof x.value
// ^?
// Shows unbound B
π Actual behavior
The type of x
is { value: B }
, where B
is an unbound generic that leaked from box
π Expected behavior
The type of x
is { value: number }
Related Issues
/cc @samholmes