I recently came across some code that I inherited which appears like this:
String.fromCharCode.apply(null, new Uint8Array(license));
Recently, we updated our project dependencies to TypeScript 3, which raised an error stating:
Argument of type 'Uint8Array' is not assignable to parameter of type 'number[]'.
Type 'Uint8Array' is missing the following properties from type 'number[]': pop, push, concat, shift, and 3 more.
I noticed similar issues in other parts of the code, all related to Uint8Array except for one instance that involved a Uint16Array. It seems the problem stems from changes in the Uint8Array constructor, which has multiple overloads. I attempted to modify the code like so:
const jsonKey: string = String.fromCharCode.apply(null, Array.from(new Uint8Array(license)));
and
const jsonKey: string = String.fromCharCode.apply(null, Array.prototype.slice.call(new Uint8Array(license)));
Unfortunately, neither of these solutions successfully replicated the original functionality of the code, although they did suppress the error messages.