GoogleChromeLabs / GoogleChromeLabs/comlink

Using `...` syntax on exposed API.

Open
#505 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12.8k
Forks
435
PR merge metrics
No merged PRs in 30d

Description

Hey team, I just had some fun debugging this! I have some code where I essentially do:

```
function blah (...args) {
const api = Comlink.wrap(worker);
return api[name](...args);
}
```

Where the splat function call transpiles to:

```
return api[name].apply(api, args);
```

The `.apply` triggers the `get` trap on the `Proxy` which returns another `Proxy`, and chaos ensues 😅

I guess you could maybe add another guard to the `get` trap for this case? For now I'll just target ES2015!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.