Skip to content

Commit 5828460

Browse files
committed
Core typedefs for date and regExp
1 parent 1313bb8 commit 5828460

File tree

14 files changed

+23
-21
lines changed

14 files changed

+23
-21
lines changed

compiler/ml/ast_untagged_variants.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) =
166166
| Tconstr (path, _, _) when Path.same path Predef.path_array -> Some Array
167167
| Tconstr (path, _, _) -> (
168168
match Path.name path with
169-
| "Js_date.t" -> Some Date
170-
| "Js_re.t" -> Some RegExp
169+
| "CoreTypes.date" -> Some Date
170+
| "CoreTypes.regExp" -> Some RegExp
171171
| "Js_file.t" -> Some File
172172
| "Js_blob.t" -> Some Blob
173173
| _ -> None)

lib/es6/CoreTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

lib/js/CoreTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

runtime/CoreTypes.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type date
2+
3+
type regExp

runtime/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 = CoreTypes.date
22

33
type msSinceEpoch = float
44

runtime/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 = CoreTypes.date
99

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

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 = CoreTypes.date
3333

3434
@send
3535
/**

runtime/Js_re.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and subsequent uses will continue the search from the previous [`lastIndex`]().
3131
*/
3232

3333
/** The RegExp object. */
34-
type t
34+
type t = CoreTypes.regExp
3535

3636
/** The result of a executing a RegExp on a string. */
3737
type result

runtime/Pervasives.res

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
/**
2-
Since [others] depend on this file, its public mli files **should not
3-
export types** introduced here, otherwise it would cause
4-
conflicts here.
1+
/* Core type aliases */
52

6-
If the type exported here is also exported in modules from others,
7-
you will get a type not equivalent.
8-
*/
9-
@deprecated("Do not use. This will be removed in v13")
10-
external /* Internal */
3+
type date = CoreTypes.date
4+
type regExp = CoreTypes.regExp
115

12-
__unsafe_cast: 'a => 'b = "%identity"
6+
/* Internal */
7+
8+
@deprecated("Do not use. This will be removed in v13")
9+
external __unsafe_cast: 'a => 'b = "%identity"
1310

1411
/* Exceptions */
1512

runtime/RegExp.res

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

33
module Result = {
44
type t = array<option<string>>

tests/gentype_tests/typescript-react-example/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/gentype_tests/typescript-react-example/src/nested/Types.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ type instantiateTypeParameter = ocaml_array<someRecord>
122122
@genType @genType.as("Vector")
123123
type vector<'a> = ('a, 'a)
124124

125-
@genType type date = Js.Date.t
125+
@genType type date = Date.t
126126

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

tests/syntax_tests/data/idempotency/pupilfirst/shared/DateTime.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 = Date.t
22

33
@val @module("date-fns")
44
external dateFormat: (t, string) => string = "format"

tests/syntax_tests/data/idempotency/pupilfirst/shared/DateTime.resi

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 = Date.t
22

33
type format =
44
| OnlyDate

0 commit comments

Comments
 (0)