I am confused as to why, in my situation, <T>
is considered a number but cannot be assigned to a parameter of type number. Changing the type of n
to either number
or any
resolves the issue.
Error:
https://i.sstatic.net/h1GE9.png
Code:
const dropFoo = <T>(arr: T[], n: T): T[] => {
return _.drop(arr, n)
};
const drop = dropFoo<number>([1, 2, 3], 1);
console.log(drop);