You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceAnimal{name: string}interfaceCatextendsAnimal{sound: string}functionhandleAnimal(animal: Cat): CatfunctionhandleAnimal(animal: Animal): AnimalfunctionhandleAnimal(animal: Cat|Animal){if('sound'inanimal){returnanimal}returnanimal}declareletcat0: Cat// when use in Array.prototype.map with shorthand callback, it is not ok// typeof list2 will be Animal[]constlist=[cat0].map(handleAnimal)// when use in Array.prototype.map with not-shorthand callback, it is ok// typeof list2 will be Cat[]constlist2=[cat0].map((catItem)=>{constcat=handleAnimal(catItem)returncat})
🙁 Actual behavior
constlist=[cat0].map(handleAnimal)// type of list: Animal[]
🙂 Expected behavior
constlist=[cat0].map(handleAnimal)// type of list: Cat[]
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
is:issue array callback function overload
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
The text was updated successfully, but these errors were encountered: