fix(client): Allow calling toString and valueOf on the proxy object
Fixes #2509
When a hono client is instantiated in expo and then console.log(client) is called, an error is thrown:
TypeError: Cannot determine default value of object
This is because the hermes javascript engine expects new String(val) to always return a string. But the proxy object would return a ClientRequestImpl object instead.
This commit makes a string / function returned in the cases where .toString() and .valueOf() is called on the function.name or function respectively.
Also see https://github.com/facebook/hermes/issues/205
Author should do the followings, if applicable
- [X] Add tests
- [X] Run tests (vitest seems to mess up the bun test runner, so comment out that import)
- [X]
yarn denoifyto generate files for Deno
Hi @ibash
Thank you for the PR. Almost everything is okay. But can you fix the TypeScript errors? I think it's not a problem to use // @ts-ignore.
@yusukebe woops, sorry about that, fixed!
@ibash
Thanks! I'll merge this now.