1
1
module Instance = struct
2
2
type t =
3
- | Array
4
- | Promise
5
- | Date
6
- | RegExp
7
- | File
3
+ | Array
8
4
| Blob
9
- let to_string = function
5
+ | Date
6
+ | File
7
+ | Promise
8
+ | RegExp
9
+ let to_string = function
10
10
Array -> " Array"
11
+ | Blob -> " Blob"
12
+ | Date -> " Date"
13
+ | File -> " File"
11
14
| Promise -> " Promise"
12
- | Date -> " Date"
13
15
| RegExp -> " RegExp"
14
- | File -> " File"
15
- | Blob -> " Blob"
16
16
end
17
17
18
18
type untaggedError =
@@ -143,9 +143,13 @@ let type_is_builtin_object (t : Types.type_expr) =
143
143
144
144
let type_to_instanceof_backed_obj (t : Types.type_expr ) =
145
145
match t.desc with
146
+ | Tconstr (path , _ , _ ) when Path. same path Predef. path_promise ->
147
+ Some Instance. Promise
148
+ | Tconstr (path , _ , _ ) when Path. same path Predef. path_array ->
149
+ Some Array
146
150
| Tconstr (path , _ , _ ) -> (
147
151
match Path. name path with
148
- | "Js.Date.t" | "Js_date.t" -> Some (Instance. Date )
152
+ | "Js.Date.t" | "Js_date.t" -> Some (Date )
149
153
| "Js.Re.t" | "Js_re.t" | "RescriptCore.Re.t" ->
150
154
(* TODO: Get rid of explicit Core by digging through aliases *)
151
155
Some (RegExp )
@@ -167,12 +171,6 @@ let get_block_type ~env (cstr : Types.constructor_declaration) :
167
171
| true , Cstr_tuple [{desc = Tconstr (path, _, _)}]
168
172
when Path. same path Predef. path_float ->
169
173
Some FloatType
170
- | true , Cstr_tuple [{desc = Tconstr (path, _, _)}]
171
- when Path. same path Predef. path_array ->
172
- Some (InstanceType Array )
173
- | true , Cstr_tuple [{desc = Tconstr (path, _, _)}]
174
- when Path. same path Predef. path_promise ->
175
- Some (InstanceType Promise )
176
174
| true , Cstr_tuple [({desc = Tconstr _} as t)]
177
175
when Ast_uncurried_utils. typeIsUncurriedFun t ->
178
176
Some FunctionType
0 commit comments