Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Move core typedefs out of Js modules #7129

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. */
6 changes: 6 additions & 0 deletions packages/artifacts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ lib/es6/BigInt64Array.js
lib/es6/BigUint64Array.js
lib/es6/Char.js
lib/es6/Console.js
lib/es6/CoreTypes.js
lib/es6/DataView.js
lib/es6/Date.js
lib/es6/Dict.js
Expand Down Expand Up @@ -244,6 +245,7 @@ lib/js/BigInt64Array.js
lib/js/BigUint64Array.js
lib/js/Char.js
lib/js/Console.js
lib/js/CoreTypes.js
lib/js/DataView.js
lib/js/Date.js
lib/js/Dict.js
Expand Down Expand Up @@ -649,6 +651,10 @@ lib/ocaml/Console.cmt
lib/ocaml/Console.cmti
lib/ocaml/Console.res
lib/ocaml/Console.resi
lib/ocaml/CoreTypes.cmi
lib/ocaml/CoreTypes.cmj
lib/ocaml/CoreTypes.cmt
lib/ocaml/CoreTypes.res
lib/ocaml/DataView.cmi
lib/ocaml/DataView.cmj
lib/ocaml/DataView.cmt
Expand Down
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