I have a function that send an object that got { name: { value: string }, + some unknown property }, how can I type my parameter to accept this object if he got at least { name: { value: string } } ?
Example:
// Working but is there a specific type to explicitly do this without [x:string]: any ?
const sortNameV2 = (array: Array<{ name: { value: string }, [x:string]: any }>, sortOrder: 'ASC' | 'DESC') => {
return [...array]
.sort((a, b) =>
a.name.value.localeCompare(b.name.value)
)
}
sortNameV2([{ name: { value: 'titi'}, id: 1 }], 'ASC')