Search code examples
f#fable-f#elmish

Syntax confusion in Fable with EventTarget


I'm new to Fable/Elmish/React, and I'm trying to understand the syntax to cast an EventTarget so I can get to the .value

The examples I can find all use the

input [ Value model.Value
          OnChange (fun ev -> ev.target?value |> string
         ]

However I get

None of the types 'EventTarget, string' support the operator '?'

Instead I have to use the following syntax

input [ Value model.Value
          OnChange (fun ev -> (ev.target:?> HTMLInputElement ).value
         ]

So what gives? Am I referencing different assemblies?


Solution

  • You need to

    open Fable.Core.JsInterop
    

    to see the operator ?