From 3a1e2413c68d07077dc442af141c53ea117b3098 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Fri, 21 Feb 2025 00:51:18 +0900 Subject: [PATCH 1/2] fix `Intl.Segments#containing` return value type --- src/lib/es2022.intl.d.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lib/es2022.intl.d.ts b/src/lib/es2022.intl.d.ts index 8fd53f7afe7ca..c4563737beaad 100644 --- a/src/lib/es2022.intl.d.ts +++ b/src/lib/es2022.intl.d.ts @@ -11,15 +11,27 @@ declare namespace Intl { granularity?: "grapheme" | "word" | "sentence" | undefined; } + /** + * The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) + */ interface Segmenter { /** * Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity. * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment) + * * @param input - The text to be segmented as a `string`. * * @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity. */ segment(input: string): Segments; + /** + * The `resolvedOptions()` method of `Intl.Segmenter` instances returns a new object with properties reflecting the options computed during initialization of this `Segmenter` object. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions) + * */ resolvedOptions(): ResolvedSegmenterOptions; } @@ -32,13 +44,20 @@ declare namespace Intl { [Symbol.iterator](): SegmentIterator; } + /** + * 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. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments) + */ interface Segments { /** * Returns an object describing the segment in the original string that includes the code unit at a specified index. * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing) + * * @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`. */ - containing(codeUnitIndex?: number): SegmentData; + containing(codeUnitIndex?: number): SegmentData | undefined; /** Returns an iterator to iterate over the segments. */ [Symbol.iterator](): SegmentIterator; @@ -58,6 +77,11 @@ declare namespace Intl { isWordLike?: boolean; } + /** + * The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) + */ const Segmenter: { prototype: Segmenter; From 3e59841d390fcaf03bad7afc2096955318908bcb Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Fri, 21 Feb 2025 00:54:09 +0900 Subject: [PATCH 2/2] format --- src/lib/es2022.intl.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2022.intl.d.ts b/src/lib/es2022.intl.d.ts index c4563737beaad..38fb0ed13f2a1 100644 --- a/src/lib/es2022.intl.d.ts +++ b/src/lib/es2022.intl.d.ts @@ -31,7 +31,7 @@ declare namespace Intl { * The `resolvedOptions()` method of `Intl.Segmenter` instances returns a new object with properties reflecting the options computed during initialization of this `Segmenter` object. * * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions) - * */ + */ resolvedOptions(): ResolvedSegmenterOptions; }