Say I have an array of objects and of the keys is called render which can be an optional function that takes a parameter (of which the type is unknown)
const array = [{a: 1}, {b: 2, render: renderFunction}, {c: 3, render: anotherFunction}]
say the 2nd object renderFunction takes a number as a param and anotherFunction takes a string as the param, how do I achieve that with generics?
const array: ArrayType<unknown> = [
{a: 1},
{b: 2, render: renderFunction} as MyType<number>,
{c: 3, render: anotherFunction} as MyType<string>
]
but this doesn't work Type 'unknown' is not assignable to type 'number'
any ideas?