Given this function declaration:
someFunc(): void {
if(__DEV__) {
this.someOtherFunc.apply(this, arguments);
}
}
When I attempt to call it with parameters, it throws an error resembling the following:
- TS2554: Expected 0 arguments, but received 2.
The conventional approach would involve utilizing the rest
operator instead of relying on arguments
. However, I am hesitant to adopt this method due to my usage of a compilation variable __DEV__
, as I wish for the method to be removed during build time when __DEV__
is false. Furthermore, employing the rest operator in TypeScript results in additional code being generated when targeting ES5.
Is there an alternative solution in TypeScript that does not necessitate placing @ts-ignore
throughout the code wherever the method is utilized?