Skip to content

Commit 8518a87

Browse files
authored
fix Intl.Segments#containing return value type (#61236)
1 parent 6d684e3 commit 8518a87

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/lib/es2022.intl.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,27 @@ declare namespace Intl {
1111
granularity?: "grapheme" | "word" | "sentence" | undefined;
1212
}
1313

14+
/**
15+
* The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string.
16+
*
17+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
18+
*/
1419
interface Segmenter {
1520
/**
1621
* Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity.
1722
*
23+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment)
24+
*
1825
* @param input - The text to be segmented as a `string`.
1926
*
2027
* @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity.
2128
*/
2229
segment(input: string): Segments;
30+
/**
31+
* The `resolvedOptions()` method of `Intl.Segmenter` instances returns a new object with properties reflecting the options computed during initialization of this `Segmenter` object.
32+
*
33+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
34+
*/
2335
resolvedOptions(): ResolvedSegmenterOptions;
2436
}
2537

@@ -32,13 +44,20 @@ declare namespace Intl {
3244
[Symbol.iterator](): SegmentIterator<T>;
3345
}
3446

47+
/**
48+
* A `Segments` object is an iterable collection of the segments of a text string. It is returned by a call to the `segment()` method of an `Intl.Segmenter` object.
49+
*
50+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments)
51+
*/
3552
interface Segments {
3653
/**
3754
* Returns an object describing the segment in the original string that includes the code unit at a specified index.
3855
*
56+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing)
57+
*
3958
* @param codeUnitIndex - A number specifying the index of the code unit in the original input string. If the value is omitted, it defaults to `0`.
4059
*/
41-
containing(codeUnitIndex?: number): SegmentData;
60+
containing(codeUnitIndex?: number): SegmentData | undefined;
4261

4362
/** Returns an iterator to iterate over the segments. */
4463
[Symbol.iterator](): SegmentIterator<SegmentData>;
@@ -58,6 +77,11 @@ declare namespace Intl {
5877
isWordLike?: boolean;
5978
}
6079

80+
/**
81+
* The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string.
82+
*
83+
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
84+
*/
6185
const Segmenter: {
6286
prototype: Segmenter;
6387

0 commit comments

Comments
 (0)