interface IAction<K extends keyof IThing> {
name: K;
value: IThing[K];
}
function assign<K extends keyof IThing>(thing: IThing, action: IAction<K>): void {
thing[action.name] = action.value;
}
const action = { name: 'someProp', value: 'someValue' } as const;
assign(state.thing, action); // ok
$ npm install