Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[PoC] Gentype emit TS assertions to let TS validate that bindings are correct#7879

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
zth wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromgentype-satisfies
Draft
Show file tree
Hide file tree
Changes from1 commit
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
NextNext commit
base
  • Loading branch information
@zth
zth committedSep 11, 2025
commitdeb38a118123ad285e112e90a3f23761d9846cf7
4 changes: 3 additions & 1 deletioncompiler/bsb/bsb_parse_sources.ml
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionscompiler/ext/literals.ml
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionscompiler/gentype/Annotation.ml
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp