Following the docs here: https://fable.io/docs/communicate/js-from-fable.html#Plain-Old-JavaScript-Objects .
I was expecting the code below to raise warnings when building it!
```f#
module App
open Fable.Core.JsInterop
open Fable.Import
open Fable.Core
type IMyInterface =
abstract foo: string with get, set
abstract bar: float with get, set
abstract baz: int option with get, set
// Warning, "foo" must be a string
let x: IMyInterface = !!{| foo = 5; bar = 4.; baz = Some 0 |}
// Warning, "bar" field is missing
let y: IMyInterface = !!{| foo = "5"; bAr = 4.; baz = Some 0 |}
// Ok, "baz" can be missing because it's optional
let z: IMyInterface = !!{| foo = "5"; bar = 4. |}
let print(x: IMyInterface) =
Browser.Dom.console.error(x)
print(x)
print(y)
print(z)
Browser.Dom.console.log(y)
Browser.Dom.console.log(z)
```
Expected a warning, got nothing.
$ npm show fable-compiler version
LOL, I expected even no warning, then I read the linked documentation.
I should have marked this feature as experimental ;)
It seems the F# compiler introduced some extra bindings to fix https://github.com/dotnet/fsharp/issues/6487 so Fable wasn't reading the AST properly. It will be fixed in the next Fable release :+1:
@alfonsogarciacaro thank you for the quick answer!
type IMyInterface =
abstract foo: string with get, set
abstract bar: float with get, set
abstract baz: int option with get, set
type INoWarning =
inherit IMyInterface
abstract more : string with get, set
// Warning, "more" is missing
let p: INoWarning = !!{| foo = 5; bar = 4. |}
// Warning, foo is the wrong type
let r: INoWarning = !!{| more= ""; foo = 5; bar = 4. |}
// Ok, all is fine!
let q: INoWarning = !!{| more= ""; foo = "5"; bar = 4. |}
@alfonsogarciacaro I think I found an unexpected behavior with the code above!
The compiler only shows the first expected warning but not the second!
I am assuming it has to do with inheritance but I am not fully sure!
Let me know if I should open another issue :D
Yeah, I think we're not supporting interface inheritance in this feature yet. Ok, let's open again this issue and I'll have a look. Hopefully it's not too difficult to fix :)