diff --git a/CHANGELOG.md b/CHANGELOG.md index ba2a0b5c2b..2ca2742683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Allow `private` in with constraints. https://github.com/rescript-lang/rescript-compiler/pull/6843 - Add regex literals as syntax sugar for `@bs.re`. https://github.com/rescript-lang/rescript-compiler/pull/6776 - Improved mechanism to determine arity of externals, which is consistent however the type is written. https://github.com/rescript-lang/rescript-compiler/pull/6874 https://github.com/rescript-lang/rescript-compiler/pull/6881 https://github.com/rescript-lang/rescript-compiler/pull/6883 +- Add `Js.globalThis` object binding. https://github.com/rescript-lang/rescript-compiler/pull/6909 #### :boom: Breaking Change diff --git a/jscomp/others/js.res b/jscomp/others/js.res index 10ce264026..6f828e95eb 100644 --- a/jscomp/others/js.res +++ b/jscomp/others/js.res @@ -77,6 +77,9 @@ Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latt /** JS object type */ type t<'a> = {..} as 'a +/** JS global object reference */ +@val external globalThis: t<'a> = "globalThis" + /** Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t. */ diff --git a/jscomp/runtime/js.res b/jscomp/runtime/js.res index 420be9c836..2958a8012b 100644 --- a/jscomp/runtime/js.res +++ b/jscomp/runtime/js.res @@ -77,6 +77,9 @@ Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latt /** JS object type */ type t<'a> = {..} as 'a +/** JS global object reference */ +@val external globalThis: t<'a> = "globalThis" + /** Nullable value of this type can be either null or 'a. This type is equivalent to Js.Null.t. */