@flo-pereira’s solution is probably the better one, but generally you can deactivate the warning for as many lines as you want and then activate it again:
@@warning("-27")
let deepClone = (obj: 'a): 'a => %raw(`
JSON.parse(JSON.stringify(obj))
`);
@@warning("+27")
Thanks for all of the suggestions. I’m going to go with the _obj solution since it avoids having to use @@warning. The %raw(`function(obj){...}`) solution has the unfortunate side-effect that return values are typed as 'a instead of preserve the type of the argument.
are just in a vanilla .res file. If i have them without the @@warning set, then I get warnings of foo is never used and bar is never used, which is what I would expect. But if I have them as i posted above with the @@warning set, then I get no warnings for either being unused. I would have expected it to give me a warning of bar is never used since i re-enabled the warning?
if you have it in the toplevel of your .res file without interface file, then those values will be exported and no warning about unused value will be shown, see for example:
module Foo: {
let baz: int
} = {
@@warning("-32")
let foo = 4
@@warning("+32")
// bar will raise a warning here
let bar = 3
let baz = 5
}
module Foo2 = {
// no warnings here
let foo2 = 4
let bar2 = 3
}