Still looking for ideas?
In our codebase we sometimes make use of Obj.magic(x)
, typically when dealing with JSON or js interop in an area we don’t care that much to do strict decoding
Sometimes though the type resolves to something unexpected and then the error is hard to trace.
A useful lint rule would be to require obj.magic to always specify the type you are expecting to cast it to
let x = Obj.magic(1) // lint error!
let x: int = Obj.magic(1) // Ok!
let x = (Obj.magic(1) : int) // Ok!