function test(data){
console.log(data)
}
test({comments: 'hi', eat: true, sleep: true})
In the test function, I am sure of the comment argument will appear, where as for other arguments, the properties might be dynamic but the value will be of boolean type,
test({comments: 'hi', drink: true, sleep: true})
considering this situation, how should I correctly type data? I have tried something like this, but it seems wrong
function(data: {data: {comments: string, [key: string]: boolean})
data, which should be an object with at least one property namedcommentsof type string, but which could have lots of other properties that I don't care about"?type DataType = { comments: string; [key: string]: unknown; };will work. Ref: stackoverflow.com/a/33860616