Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Nameof operator

$
0
0

So something along these lines:

const handler = {
  get: function (target, property, receiver) {
    return property;
  },
};

let nameof = (instance, getProperty) => {
  const p = new Proxy(instance, handler);
  return getProperty(p);
};

// Example property access
let y = { bar: 3 }
console.log(nameof(y, (y) => y.bar));

?


Viewing all articles
Browse latest Browse all 2592

Trending Articles