Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty proxy object returned when target is empty object #83

Open
stingrayfunk opened this issue Jan 22, 2023 · 0 comments
Open

Empty proxy object returned when target is empty object #83

stingrayfunk opened this issue Jan 22, 2023 · 0 comments

Comments

@stingrayfunk
Copy link

stingrayfunk commented Jan 22, 2023

I'm using a third-party library that uses Proxy and I'm attempting to use your polyfill in IE11.

They're using it like this:

  return new Proxy(
    {},
    {
      get: (_, propKey): unknown => {
        if (isAppRoute(router)) {
          switch (propKey) {
            case 'query':
              return getRouteQuery(router, args);
            case 'mutation':
              return getRouteQuery(router, args);
            case 'useQuery':
              return getRouteUseQuery(router, args);
            case 'useInfiniteQuery':
              return getRouteUseInfiniteQuery(router, args);
            case 'useQueries':
              return getRouteUseQueries(router, args);
            case 'useMutation':
              return getRouteUseMutation(router, args);
            default:
              throw new Error(`Unknown method called on ${String(propKey)}`);
          }
        } else {
          const subRouter = router[propKey as string];

          return createNewProxy(subRouter, args);
        }
      },
    }
  );

Source: https://github.com/ts-rest/ts-rest/blob/main/libs/ts-rest/react-query/src/lib/react-query.ts#L344

So they pass {} as the target argument.

When I use your polyfill, I get an empty Proxy object back. Can someone please help with why this is the case? Does your polyfill support this type of usage?

Without the polyfill, this usage works fine in modern browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant