Skip to content

Types for TextDecoder.decode missing second argument #1205

@IGx89

Description

@IGx89

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions