Open
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);