Skip to content

Commit 0ae1f60

Browse files
committed
Fix Js.String.match_ return type
Javscript String.prototype.match function can return undefined values for optional capture groups that are not found, which breaks the type annotations since this is not added as a Js.nullable or an option, it's not possible to deal with those. Added an option type for array values.
1 parent d5d46b3 commit 0ae1f60

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

jscomp/others/js_string.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ external localeCompare : t -> float = "localeCompare" [@@bs.send.pipe: t]
274274
]}
275275
276276
*)
277-
external match_ : Js_re.t -> t array option = "match" [@@bs.send.pipe: t] [@@bs.return {null_to_opt}]
277+
external match_ : Js_re.t -> t option array option = "match" [@@bs.send.pipe: t] [@@bs.return {null_to_opt}]
278278

279279
(** [normalize str] returns the normalized Unicode string using Normalization Form Canonical (NFC) Composition.
280280

jscomp/others/js_string2.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ external localeCompare : t -> t -> float = "localeCompare" [@@bs.send]
273273
]}
274274
275275
*)
276-
external match_ : t -> Js_re.t -> t array option = "match" [@@bs.send] [@@bs.return {null_to_opt}]
276+
external match_ : t -> Js_re.t -> t option array option = "match" [@@bs.send] [@@bs.return {null_to_opt}]
277277

278278
(** [normalize str] returns the normalized Unicode string using Normalization Form Canonical (NFC) Composition.
279279

0 commit comments

Comments
 (0)