Skip to content

Commit 83319d8

Browse files
committed
apply a warning when bs.string can be safely removed
1 parent 45d9bf3 commit 83319d8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

jscomp/syntax/ast_polyvar.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,14 @@ let map_row_fields_into_strings ptyp_loc
112112
| `Nothing -> Bs_syntaxerr.err ptyp_loc Invalid_bs_string_type
113113
| `Null
114114
| `NonNull ->
115-
External_arg_spec.Poly_var {has_payload = case = `NonNull ;
116-
descr = if !has_bs_as then Some result else None }
115+
let has_payload = case = `NonNull in
116+
let descr = if !has_bs_as then Some result else None in
117+
if not has_payload && descr = None then begin
118+
Location.prerr_warning ptyp_loc (Bs_ffi_warning "bs.string is redundant here, you can safely remove it")
119+
end;
120+
External_arg_spec.Poly_var
121+
{has_payload ;
122+
descr }
117123

118124
let is_enum row_fields =
119125
List.for_all (fun (x : Parsetree.row_field) ->

0 commit comments

Comments
 (0)