Correctly handle generic functions (e.g.: Object.freeze
) passed as callbacks to generic functions (e.g.: Array.prototype.map
)
#42862
Labels
Has Repro
This issue has compiler-backed repros: https://aka.ms/ts-repros
In Discussion
Not yet reached consensus
Suggestion
An idea for TypeScript
Suggestion
🔍 Search Terms
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
A generic transforming function (e.g.:
Object.freeze
) passed as a callback to a generic mapping function (such asArray.prototype.map
), should be handled similarly to an arrow function with inferred types.📃 Motivating Example
From engine262/src/engine.mjs:
Workbench Repro
Expected type:
Like when using an arrow function:
Workbench Repro
Actual type:
💻 Use Cases
Getting correct type inference for JavaScript code on the wild web.
Related issues
readonly
type operator to allow correct definition ofObject.freeze
#10725The text was updated successfully, but these errors were encountered: