Home > Enterprise >  Property 'foo' does not exist on type '{}' when using new Proxy({}), .....)
Property 'foo' does not exist on type '{}' when using new Proxy({}), .....)

Time:01-05

I'm not using typescript (and, right now I don't intend to) but the default set up for VSCode seems to have put some checking in for me. It's kind of handy, kind of a pain. I want to stick with it for now.

My code that causes this issue is:

  let {
    localApiVersion, localDate, remoteVersion, remoteDate,
  } = new Proxy({}, { get: () => null });

Which I took from my tooltip on highlighting 'localApiVersion' which reads: let localApiVersion: string

Using typedef will also work:

  /**
   * @typedef {Object.<string, (null|string)>} InitProxy
   */

  let {
    localApiVersion, localDate, remoteVersion, remoteDate,
  } = /** @type {InitProxy} */ (new Proxy({}, { get: () => null }));

But this is getting into the levels of verbosity I'm trying to avoid.

  •  Tags:  
  • Related