Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Empty proxy object returned when target is empty object #83

@stingrayfunk

Description

@stingrayfunk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions