I want to get the key map from any object,
I've implemented the function,
but I can't make typescript happy,
what should I do without using acc: any
const origin = {
a: 1,
b: 'string',
c: () => {}
};
function getObjKeyMap<T>(obj: T) {
return Object.keys(obj).reduce((acc, k) => {
/* Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.ts(7053) */
acc[k] = k;
return acc;
}, {});
}
const keyMap = getObjKeyMap(origin);