Bug Report
π Search Terms
typeof, generic, return type, inference
π Version & Regression Information
Tested with TypeScript 4.6.2 only
β― Playground Link
Playground link with relevant code (includes a few extra variations on the issue)
π» Code
let value = 1
function decorate<O extends any>(fn: (first: {value: typeof value}) => O) {
return (): O => fn({value})
}
let f = decorate(({value}) => 5)
π Actual behavior
The type of f is () => unknown.
π Expected behavior
The type of f should be () => number. If typeof value (from the code example) is replaced with number, then the code behaves as expected. The code also behaves as expected when first is not an object.
Bug Report
π Search Terms
typeof,generic,return type,inferenceπ Version & Regression Information
Tested with TypeScript 4.6.2 only
β― Playground Link
Playground link with relevant code (includes a few extra variations on the issue)
π» Code
π Actual behavior
The type of
fis() => unknown.π Expected behavior
The type of
fshould be() => number. Iftypeof value(from the code example) is replaced withnumber, then the code behaves as expected. The code also behaves as expected whenfirstis not an object.