I'm trying to store typescript object with key as string and value as number | number [] | string.
interface Person {
[ key : string] : number | number[] | string
}
const person:Person = {
"name" : "Harsha",
"marks" : [ 89, 90 , 100 , 67],
"class" : 8
}
function hundredsCount(marks: number[]) {
const count:number = marks.map((each:number) => each).length
}
hundredsCount(person[marks])
When I call hundredsCount then facing an error : Argument of type 'string | number | number[]' is not assignable to parameter of type 'number[]'. Type 'string' is not assignable to type 'number[]'.
hundredsCount
function – Ramesh ReddyhundredsCount(person.marks)
orhundredsCount(person["marks"])
– uminder