Skip to content

Commit

Permalink
Core typedefs for date and regExp
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Oct 25, 2024
1 parent 1313bb8 commit 5828460
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions compiler/ml/ast_untagged_variants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) =
| Tconstr (path, _, _) when Path.same path Predef.path_array -> Some Array
| Tconstr (path, _, _) -> (
match Path.name path with
| "Js_date.t" -> Some Date
| "Js_re.t" -> Some RegExp
| "CoreTypes.date" -> Some Date
| "CoreTypes.regExp" -> Some RegExp
| "Js_file.t" -> Some File
| "Js_blob.t" -> Some Blob
| _ -> None)
Expand Down
1 change: 1 addition & 0 deletions lib/es6/CoreTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
1 change: 1 addition & 0 deletions lib/js/CoreTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
3 changes: 3 additions & 0 deletions runtime/CoreTypes.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type date

type regExp
2 changes: 1 addition & 1 deletion runtime/Date.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js.Date.t
type t = CoreTypes.date

type msSinceEpoch = float

Expand Down
2 changes: 1 addition & 1 deletion runtime/Date.resi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
A type representing a JavaScript date.
*/
type t = Js.Date.t
type t = CoreTypes.date

/**
Time, in milliseconds, since / until the UNIX epoch (January 1, 1970 00:00:00 UTC).
Expand Down
2 changes: 1 addition & 1 deletion runtime/Js_date.res
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ on MDN.) JavaScript stores dates as the number of milliseconds since the UNIX
*epoch*, midnight 1 January 1970, UTC.
*/

type t
type t = CoreTypes.date

@send
/**
Expand Down
2 changes: 1 addition & 1 deletion runtime/Js_re.res
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and subsequent uses will continue the search from the previous [`lastIndex`]().
*/

/** The RegExp object. */
type t
type t = CoreTypes.regExp

/** The result of a executing a RegExp on a string. */
type result
Expand Down
17 changes: 7 additions & 10 deletions runtime/Pervasives.res
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/**
Since [others] depend on this file, its public mli files **should not
export types** introduced here, otherwise it would cause
conflicts here.
/* Core type aliases */

If the type exported here is also exported in modules from others,
you will get a type not equivalent.
*/
@deprecated("Do not use. This will be removed in v13")
external /* Internal */
type date = CoreTypes.date
type regExp = CoreTypes.regExp

__unsafe_cast: 'a => 'b = "%identity"
/* Internal */

@deprecated("Do not use. This will be removed in v13")
external __unsafe_cast: 'a => 'b = "%identity"

/* Exceptions */

Expand Down
2 changes: 1 addition & 1 deletion runtime/RegExp.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js.Re.t
type t = CoreTypes.regExp

module Result = {
type t = array<option<string>>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type instantiateTypeParameter = ocaml_array<someRecord>
@genType @genType.as("Vector")
type vector<'a> = ('a, 'a)

@genType type date = Js.Date.t
@genType type date = Date.t

@genType let currentTime = Js.Date.make()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js.Date.t
type t = Date.t

@val @module("date-fns")
external dateFormat: (t, string) => string = "format"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js.Date.t
type t = Date.t

type format =
| OnlyDate
Expand Down

0 comments on commit 5828460

Please sign in to comment.