hono icon indicating copy to clipboard operation
hono copied to clipboard

fix(client): Allow calling toString and valueOf on the proxy object

Open ibash opened this issue 1 year ago • 2 comments

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 denoify to generate files for Deno

ibash avatar Apr 15 '24 01:04 ibash

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 avatar Apr 16 '24 03:04 yusukebe

@yusukebe woops, sorry about that, fixed!

ibash avatar Apr 17 '24 01:04 ibash

@ibash

Thanks! I'll merge this now.

yusukebe avatar Apr 17 '24 22:04 yusukebe