Skip to content

Nullable htmxTemplate & Binding Issue #34

@jamesward

Description

@jamesward

When I try to make the parameter in htmxTemplate nullable I get this compiler error:

None of the following candidates is applicable:

fun <reified CONTROLLER : Any, reified REQ : Record, RESP : Any> route(verb: HttpVerb, path: String, noinline binding: CONTROLLER.(REQ) -> RESP, crossinline renderer: TagConsumer<*>.(RESP) -> Unit): HxRoute:
  Argument type mismatch: actual type is 'HtmxTemplate<ChatResponse?>', but 'Function2<TagConsumer<*>, uninferred RESP (of fun <CONTROLLER : Any, REQ : Record, RESP : Any> route), Unit>' was expected.

fun <reified CONTROLLER : Any, reified REQ : Record, RESP : Any> route(verb: HttpVerb, path: String, noinline binding: CONTROLLER.(REQ) -> RESP, renderer: HtmxTemplate<RESP>): HxRoute:
  Argument type mismatch: actual type is 'HtmxTemplate<ChatResponse?>', but 'HtmxTemplate<uninferred RESP (of fun <CONTROLLER : Any, REQ : Record, RESP : Any> route)>' was expected.

fun <reified CONTROLLER : Any, reified REQ : Record, USER : Principal, RESP : Any> route(verb: HttpVerb, path: String, noinline binding: CONTROLLER.(USER?, REQ) -> RESP, crossinline renderer: TagConsumer<*>.(RESP) -> Unit): HxRoute:
  Argument type mismatch: actual type is 'HtmxTemplate<ChatResponse?>', but 'Function2<TagConsumer<*>, uninferred RESP (of fun <CONTROLLER : Any, REQ : Record, USER : Principal, RESP : Any> route), Unit>' was expected.

fun <reified CONTROLLER : Any, reified REQ : Record, USER : Principal, RESP : Any> route(verb: HttpVerb, path: String, noinline binding: CONTROLLER.(USER?, REQ) -> RESP, renderer: HtmxTemplate<RESP>): HxRoute:
  Argument type mismatch: actual type is 'HtmxTemplate<ChatResponse?>', but 'HtmxTemplate<uninferred RESP (of fun <CONTROLLER : Any, REQ : Record, USER : Principal, RESP : Any> route)>' was expected.

This is the binding & htmxTemplate:

interface ChatService {
    fun invocations(request: ChatRequest): ChatResponse?
}


val chatResponseTemplate = htmxTemplate<ChatResponse?> {
    div(classes = "message assistant-message") {
        div(classes = "message-content") {
            +(it?.result?.output?.text ?: "Could not get response")
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions