I have this in the main module:
import ./elm
type
State = object
elmProgram: elm.Program
portToElm: elm.SubPort[portMessages.Incoming]
# Error is with this function
proc newState(
elmProgram: elm.Program,
): State =
return State(
elmProgram: elmProgram,
portToElm: elmProgram.getSubPort("rawSubscribe"),
)
The asshole compiler told me:
Error: invalid type: 'SubPort[SubPort.T]' in this context: 'proc (elmProgram: Program): State' for proc
This is the elm module:
type
Program* {.importjs.} = ref object of JsRoot
SubPort*[T: JsRoot] {.importjs.} = ref object of JsRoot
# Get a reference to a Sub port (to Elm)
proc getSubPort*[T: JsRoot](
program: Program,
name: cstring,
): SubPort[T] {.importjs: "#.ports[#]".}
looks like you ran into the same problem as https://forum.nim-lang.org/t/7798
why is SubPort generic?