swiftwasm / swiftwasm/JavaScriptKit

[BridgeJS] Uncaught TypeError: import object field '<project>' is not an Object

Open
#672 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
986
Forks
76
Avg merge
21h 11m
Merged PRs (30d)
4

Description

When using ElementaryUI and BridgeJS combined compilation succeeds but runtime crashes on start with:

Uncaught TypeError: import object field '<project>' is not an Object
@View
struct Counter {
    @State var count = 0

    var body: some View {
        div {
            p { "Count: \(count)" }
            button { "Increment" }
                .onClick { count += 1 }
        }.onAppear {
            try? console().log("Hello from Swift!")
        }
    }
}

import JavaScriptKit

@JSFunction func console() throws(JSException) -> Console

@JSClass struct Console {
    @JSFunction func log(_ message: String) throws(JSException) -> Void
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the runtime crash with the ElementaryUI and BridgeJS Counter example shown in the issue. Start by inspecting the generated WebAssembly imports and the JavaScript-side import object around the field. Done means the combined compilation starts without the reported uncaught TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, swift, wasm
Domain
api, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.