core icon indicating copy to clipboard operation
core copied to clipboard

Type translation of delegate types

Open Jand42 opened this issue 8 years ago • 1 comments

Part of #820

In WebSharper 4.0, delegates translate to JS funcions, with a few extra fields: $Func for the non-bound version, and $Target for the target object. Multi-cast delegates have an $Invokes which holds the invocation list as an array. All of these are treated as optional, so that any JS function works against WS-generated code that takes delegates.

Simply translating delegate types to their function signatures should be viable for a first-pass solution. So for example Action<int> becomes number => void. And then later it is possible to switch to generate named interfaces for them, like

interface Action<T0> extends WebSharper.MulticastDelegate {
  (a:T0): void;
}
  • [x] Translated to lambda type
  • [ ] Translated to named type

Jand42 avatar Oct 13 '17 14:10 Jand42

Now translated to plain lambda signatures

Jand42 avatar Oct 13 '17 14:10 Jand42