js-compute-runtime icon indicating copy to clipboard operation
js-compute-runtime copied to clipboard

Types for TextDecoder.decode missing second argument

Open IGx89 opened this issue 3 months ago • 0 comments

Hello! While running tsc on my TypeScript code that uses TextDecoder.decode I discovered that the TypeScript types for it are incorrect.

Take a look here: https://github.com/fastly/js-compute-runtime/blob/v3.35.1/types/globals.d.ts#L881:

declare class TextDecoder {
  // TODO: We should throw a RangeError if supplied a `label` that we do not support
  constructor(label?: 'unicode-1-1-utf-8' | 'utf-8' | 'utf8');
  decode(input?: ArrayBuffer | ArrayBufferView): string;
  get encoding(): 'utf-8';
}

Note that the decode method is declared with only a single argument, but your docs and C++ code (as well as the MDN docs) support a second options argument.

That causes the following error when attempting to pass a second argument:

Image

IGx89 avatar Oct 01 '25 21:10 IGx89