slint-ui/slint · error

JsWindowEvent:: has an unnamed field

Error message

JsWindowEvent::{} has an unnamed field

What it means

While generating the window-event TypeScript module, the build script walks each WindowEvent variant's fields to emit interface properties. Named fields are required because the generator reads the field name to produce the TS property; an unnamed (tuple) field in a JsWindowEvent variant breaks that assumption, so the build panics. It fires only if someone declares a new event variant using tuple fields instead of named fields.

Solutions

  1. Give the JsWindowEvent variant field a name in the napi bindings so the generator can correlate it with the core WindowEvent field
  2. Extend the generator to handle unnamed (tuple-style) fields by synthesizing positional names
  3. Re-run the build after fixing the enum definition in the node API source
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at api/node/build.rs:410 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/b1f92f85409bc1e2. Report an issue: GitHub.

Appendix: source

Thrown at api/node/build.rs:410

        );
        docs.push(String::new());
        docs.push(" @see {@link Window.dispatchEvent}".into());
        write_jsdoc(&mut ts, "", &docs);
        ts.push_str(&format!("export interface {}Event {{\n", core_variant.name));
        ts.push_str(&format!("    type: \"{}\";\n", to_kebab_case(&core_variant.name)));

        assert_eq!(
            core_variant.fields.len(),
            napi_variant.fields.len(),
            "WindowEvent::{} and JsWindowEvent::{} have different fields",
            core_variant.name,
            napi_variant.name
        );
        for (core_field, napi_field) in core_variant.fields.iter().zip(&napi_variant.fields) {
            // A tuple variant has no field name in the core enum, so the binding names it.
            let js_name =
                napi_field.js_name.clone().or_else(|| napi_field.name.clone()).unwrap_or_else(
                    || panic!("JsWindowEvent::{} has an unnamed field", napi_variant.name),
                );
            if let Some(core_name) = &core_field.name {
                assert_eq!(
                    core_name.as_str(),
                    napi_field.name.as_deref().unwrap_or_default(),
                    "field of WindowEvent::{} renamed in JsWindowEvent",
                    core_variant.name
                );
                assert_eq!(
                    to_camel_case(core_name),
                    js_name,
                    "JsWindowEvent::{}::{core_name} needs `#[napi(js_name = \"{}\")]`",
                    napi_variant.name,
                    to_camel_case(core_name)
                );
            }
            let (ts_type, expected_napi_type) = map_event_field_type(&core_field.ty);
            assert_eq!(

View on GitHub (pinned to bb937076de)