Skip to content
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: 3 additions & 1 deletion compiler/bsb/bsb_parse_sources.ml
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,15 @@ and walk_source_dir_map (cxt : walk_cxt) sub_dirs_field =
let working_dir = Filename.concat cxt.root cxt.cwd in
if not (Set_string.mem cxt.ignored_dirs cxt.cwd) then (
let file_array = Sys.readdir working_dir in
(* Remove .gen.js/.gen.tsx during clean up *)
(* Remove .gen.js/.gen.tsx/.assertions.ts during clean up *)
Ext_array.iter file_array (fun file ->
let is_typescript = cxt.gentype_language = "typescript" in
if
(not is_typescript)
&& Ext_string.ends_with file Literals.suffix_gen_js
|| (is_typescript && Ext_string.ends_with file Literals.suffix_gen_tsx)
|| is_typescript
&& Ext_string.ends_with file Literals.suffix_assertions_ts
then Sys.remove (Filename.concat working_dir file));
let cxt_traverse = cxt.traverse in
match (sub_dirs_field, cxt_traverse) with
Expand Down
2 changes: 2 additions & 0 deletions compiler/ext/literals.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ let suffix_gen_js = ".gen.js"

let suffix_gen_tsx = ".gen.tsx"

let suffix_assertions_ts = ".assertions.ts"

let esmodule = "esmodule"

let commonjs = "commonjs"
Expand Down
16 changes: 16 additions & 0 deletions compiler/gentype/Annotation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ let tag_is_unboxed s = s = "unboxed" || s = "ocaml.unboxed"
let tag_is_gentype_import s = s = "genType.import" || s = "gentype.import"
let tag_is_gentype_opaque s = s = "genType.opaque" || s = "gentype.opaque"

let tag_is_gentype_satisfies s =
s = "genType.satisfies" || s = "gentype.satisfies"

let tag_is_one_of_the_gentype_annotations s =
tag_is_gentype s || tag_is_gentype_as s || tag_is_gentype_import s
|| tag_is_gentype_opaque s
Expand Down Expand Up @@ -163,6 +166,19 @@ let doc_string_from_attrs attributes = attributes |> get_doc_payload
let has_attribute check_text (attributes : Typedtree.attributes) =
get_attribute_payload check_text attributes <> None

let get_satisfies_path (attributes : Typedtree.attributes) : string list option
=
match attributes |> get_attribute_payload tag_is_gentype_satisfies with
| Some (_, TuplePayload payloads) ->
let rec collect acc = function
| [] -> Some (List.rev acc)
| StringPayload s :: tl -> collect (s :: acc) tl
| _ -> None
in
collect [] payloads
| Some (_, StringPayload s) -> Some [s]
| _ -> None

let from_attributes ~(config : GenTypeConfig.t) ~loc
(attributes : Typedtree.attributes) =
let default = if config.everything then GenType else NoGenType in
Expand Down
Loading
Loading