Object.keys returns an array of properties. You cannot index an array using an object; you should use a number to represent the offset from the beginning of the array.
As an equivalent example, what do you expect from this code?
var a = [1, 2, 3, 4] console.log(a[{}]);
It's pointless.
Edit: After reading the OP comments and reviewing the code again, I realized that my assessment was wrong. Although the problem is that the source code is trying to index the keys function using an object literal, the real problem is using square brackets instead of parentheses. This will work:
let keys = Object.keys(userTypes);
It calls keys with userTypes instead of an index with it.
source share