This seems like something fairly simple, but I have tried searching it multiple ways and couldn’t find an answer.
I want to specify a type for an argument that allows any objects that contain a certain key, like this:
type Action = {type : string};
function reducer(state : object, action : object extends Action) {
...
};
Something like this, but this syntax doesn’t work. That is, I want the action argument only to accept objects that contain the key “type” that is a string. If I just do this:
function (state : object, action : {type : string}) {...};
The function only accepts objects that only have the key “type”. How can I achieve this?
Thanks in advance.