Looking at
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
In TypeScript in Strict mode, I tried,
const handler = {
get: (obj:object, prop:string) => prop in obj
? obj[prop] //Error here
:37
};
const p = new Proxy({}, handler);
p.a = 1;
p.b = undefined;
console.log(p.a, p.b); // 1, undefined
console.log('c' in p, p.c); // false, 37
and getting error:
[ts] Element implicitly has an 'any' type
because type '{}' has no index signature.
(parameter) prop: string
What is the most concise and proper way to resolve thi issue?
This answer https://stackoverflow.com/a/47461946/1028880 might be related, but not sure. Thanks.