Skip to content

Commit af47499

Browse files
committed
Stdlib namespace for Core modules
1 parent d4e5c8e commit af47499

13 files changed

+39
-12
lines changed

compiler/core/res_compmisc.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ let initial_env ?modulename () =
5454
let initial = Env.initial_safe_string in
5555
let env =
5656
if !Clflags.nopervasives then initial
57-
else open_implicit_module "Pervasives" initial
57+
else
58+
initial
59+
|> open_implicit_module "Pervasives"
60+
|> open_implicit_module "Stdlib"
5861
in
5962
List.fold_left
6063
(fun env m -> open_implicit_module m env)

compiler/gentype/TranslateTypeExprFromTypes.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
8686
{dependencies = []; type_ = string_t}
8787
| (["Js"; "Types"; "bigint_val"] | ["BigInt"; "t"]), [] ->
8888
{dependencies = []; type_ = bigint_t}
89-
| (["Js"; "Date"; "t"] | ["Date"; "t"]), [] ->
89+
| (["Js"; "Date"; "t"] | ["Date"; "t"] | ["Stdlib_Date"; "t"]), [] ->
9090
{dependencies = []; type_ = date_t}
9191
| ["Map"; "t"], [param_translation1; param_translation2] ->
9292
{

compiler/ml/ast_untagged_variants.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) =
179179
| Tconstr (path, _, _) when Path.same path Predef.path_array -> Some Array
180180
| Tconstr (path, _, _) -> (
181181
match Path.name path with
182-
| "Js_date.t" -> Some Date
182+
| "Stdlib_Date.t" -> Some Date
183183
| "Js_re.t" -> Some RegExp
184184
| "Js_file.t" -> Some File
185185
| "Js_blob.t" -> Some Blob

lib/es6/Stdlib.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
4+
let $$Date;
5+
6+
export {
7+
$$Date,
8+
}
9+
/* No side effect */
File renamed without changes.

lib/js/Stdlib.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
4+
let $$Date;
5+
6+
exports.$$Date = $$Date;
7+
/* No side effect */
File renamed without changes.

runtime/Intl_DateTimeFormat.res

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,17 @@ external supportedLocalesOf: (array<string>, ~options: supportedLocalesOptions=?
113113

114114
@send external resolvedOptions: t => resolvedOptions = "resolvedOptions"
115115

116-
@send external format: (t, Date.t) => string = "format"
116+
@send external format: (t, Stdlib_Date.t) => string = "format"
117117
@send
118-
external formatToParts: (t, Date.t) => array<dateTimePart> = "formatToParts"
118+
external formatToParts: (t, Stdlib_Date.t) => array<dateTimePart> = "formatToParts"
119119

120120
@send
121-
external formatRange: (t, ~startDate: Date.t, ~endDate: Date.t) => string = "formatRange"
121+
external formatRange: (t, ~startDate: Stdlib_Date.t, ~endDate: Stdlib_Date.t) => string =
122+
"formatRange"
122123

123124
@send
124-
external formatRangeToParts: (t, ~startDate: Date.t, ~endDate: Date.t) => array<dateTimeRangePart> =
125-
"formatRangeToParts"
125+
external formatRangeToParts: (
126+
t,
127+
~startDate: Stdlib_Date.t,
128+
~endDate: Stdlib_Date.t,
129+
) => array<dateTimeRangePart> = "formatRangeToParts"

runtime/Js_date.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ on MDN.) JavaScript stores dates as the number of milliseconds since the UNIX
2929
*epoch*, midnight 1 January 1970, UTC.
3030
*/
3131

32-
type t
32+
type t = Stdlib_Date.t
3333

3434
@send
3535
/**

runtime/JsxDOM.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ type domProps = {
209209
loop?: bool,
210210
low?: int,
211211
manifest?: string /* uri */,
212-
max?: string /* should be int or Js.Date.t */,
212+
max?: string /* should be int or Date.t */,
213213
maxLength?: int,
214214
media?: string /* a valid media query */,
215215
mediaGroup?: string,

runtime/Stdlib.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Date = Stdlib_Date
2+
3+
// Aliases for convenience
4+
type date = Date.t

runtime/Date.res renamed to runtime/Stdlib_Date.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type t = Js.Date.t
1+
type t
22

33
type msSinceEpoch = float
44

runtime/Date.resi renamed to runtime/Stdlib_Date.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
A type representing a JavaScript date.
77
*/
8-
type t = Js.Date.t
8+
type t
99

1010
/**
1111
Time, in milliseconds, since / until the UNIX epoch (January 1, 1970 00:00:00 UTC).

0 commit comments

Comments
 (0)