Skip to content

Intl.Segments.prototype.containing should include undefined in return value #61235

Closed

Description

⚙ Compilation target

ESNext

⚙ Library

ESNext

Missing / Incorrect Definition

The interface Intl.Segments lacks an undefined in the return type for containing:

interface Segments {
    // Should be SegmentData | undefined
    containing(codeUnitIndex?: number): SegmentData;
}

Sample Code

const segmenter = new Intl.Segmenter();

const segments = segmenter.segment("Hello world");
// @ts-expect-error This should report an error
const s: Intl.SegmentData = segments.containing(40);
// This should be fine
const s: Intl.SegmentData | undefined = segments.containing(40);

Documentation Link

MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing#return_value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions