-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Firstly, thanks @alfonsogarciacaro for creating this tool!
I just got started playing with the tool, so chances are high this is user error. If so, my apologies ahead of time.
I have created an Elmish Svelte Store and annotated the makeStore function with [<SveltePlugins.GenerateDeclaration>] in the hopes that I would get a typescript d.ts file as well. When compiling with Fable, I get nothing besides a .js version of my F# script.
I am using:
- Fable.SvelteStore: 1.0.0-beta-006
- Fable: 3.1.5 (this is slightly higher than in your samples which use 3.1.1, but downgrading to 3.1.1 does not seem to make any difference on my end)
- dotnet 5.0.103
I'll try to debug a bit more thoroughly tomorrow (when my head is fresher), but wanted to put down some notes while it's fresh.
The F# file I am compiling has a makeStore function that looks like this:
[<SveltePlugins.GenerateDeclaration>]
let makeStore () =
let dispatchRef: (Msg -> unit) ref = ref (fun _ -> ())
let hub = SignalR.connect<Shared.SignalRHub.Action, _, _, Shared.SignalRHub.Response, _>(fun hub -> ...)
let store, dispatch = SvelteStore.makeElmish (fun () -> init hub) update (fun _ -> hub.stopNow()) ()
store, SvelteStore.makeDispatcher dispatchthe generated JavaScript ends up looking like this:
export function makeStore() {
// omitted some generated code for brevity ...
const patternInput = makeElmish(() => init(hub_2), update, (_arg5) => {
HubConnection$5__stopNow(hub_2);
}, void 0);
const store = patternInput[0];
const dispatch = patternInput[1];
return [store, {
serverMsg: (Item) => dispatch(new Msg(0, Item)),
unexpectedServerResponse: () => dispatch(new Msg(1)),
setConnected: (Item) => dispatch(new Msg(2, Item)),
createElection: () => dispatch(new Msg(3)),
addCandidate: (name) => dispatch(new Msg(4, name)),
}];
}The code is mostly as I would expect, but unfortunately the type definition interface file is missing.
The dotnet fable command I am using is modeled after the one you are using in your samples, namely: dotnet fable watch ../Absolutally.Client/ -o src/bin --exclude Fable.SveltePlugins
I have also tried using the built in --typescript flag in Fable (dotnet fable watch ../Absolutally.Client/ -o src/bin --typescript --typedArrays false), but unfortunately it ends up spitting out any types across the board, which unfortunately doesn't help me much further (but that's a fable problem, not a Fable.Store problem, hence a problem for another day):
...
const store = patternInput[0];
const dispatch = patternInput[1];
return [store, {
serverMsg: (Item: any): any => dispatch(new Msg(0, Item)),
unexpectedServerResponse: (): any => dispatch(new Msg(1)),
setConnected: (Item: any): any => dispatch(new Msg(2, Item)),
createElection: (): any => dispatch(new Msg(3)),
addCandidate: (name: any): any => dispatch(new Msg(4, name)),
}];
}Any pointers are of course welcome!