mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
4ae3a080d6
Many times in our default configuration, we need to create an empty
default implementation of a callback. The compiler wants to strip
out unused parameters from these functions, but this breaks our
runtime-type-checking for functions in configure(). We need a way to
keep the full function signature in default config callbacks in
compiled mode.
This adds a new utility: ConfigUtils.referenceParametersAndReturn().
It references the input parameters so the compiler doesn't remove them
from the calling function, and returns whatever value is specified.
The utility function is marked with `@noinline`, so the compiler won't
tamper with it.
Default config callbacks that use this utility will still bear the
complete function signature even in compiled mode.
The caller should look something like this:
```js
const callback = (a, b, c, d) => {
return referenceParametersAndReturn(
[a, b, c, d],
a); // Can be anything, doesn't need to be one of the parameters
};
```
See also https://github.com/shaka-project/shaka-player/pull/4231#discussion_r874710385