Typescript isn’t able to infer the right type of the return type

PHOTO EMBED

Fri Feb 09 2024 08:41:37 GMT+0000 (Coordinated Universal Time)

Saved by @aditya_revankar #typescript

function getFirstElement(arr: (string | number)[]) {
    return arr[0];
}
const firstEle = getFirstElement(["neil", "nithin", "mukesh"]);
firstEle.toUpperCase()
content_copyCOPY