{"record":{"id":"c5d318b2c0d769a0","repo":"slint-ui/slint","slug":"duplicated-property-name-cb-on-global-global","errorCode":null,"errorMessage":"Duplicated property name ${cb} on global ${global}","messagePattern":"Duplicated property name (.+?) on global (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"api/node/typescript/index.ts","lineNumber":558,"sourceCode":"                                                    globalName,\n                                                    prop.name,\n                                                    value,\n                                                );\n                                            },\n                                            enumerable: true,\n                                        },\n                                    );\n                                }\n                            });\n\n                        instance!\n                            .definition()\n                            .globalCallbacks(globalName)\n                            ?.forEach((cb) => {\n                                const callbackName = translateName(cb);\n\n                                if (globalObject[callbackName] !== undefined) {\n                                    console.warn(\n                                        \"Duplicated property name \" +\n                                            cb +\n                                            \" on global \" +\n                                            global,\n                                    );\n                                } else {\n                                    Object.defineProperty(\n                                        globalObject,\n                                        translateName(cb),\n                                        {\n                                            get() {\n                                                return function () {\n                                                    return instance!.invokeGlobal(\n                                                        globalName,\n                                                        cb,\n                                                        Array.from(arguments),\n                                                    );\n                                                };","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/api/node/typescript/index.ts#L540-L576","documentation":"Callbacks of a global are also attached to the global's JS object under their translated names. When a callback's camelCase key already exists on that object (a property or another callback with the colliding spelling), the bindings warn 'Duplicated property name <cb> on global <global>' and skip the callback - so invoking or setting it from JavaScript fails with an undefined member.","triggerScenarios":"On one global: callback track-changed together with property <int> trackChanged (or callback do-thing next to callback doThing); a callback renamed in .slint while a property with the equivalent camelCase name already exists.","commonSituations":"Adding a callback whose name mirrors an existing property; partial kebab/camel refactors inside globals; gluing generated and hand-written .slint fragments together.","solutions":["Rename the colliding callback or the property so the translated keys differ.","Smoke-run the app and grep the console for 'Duplicated property name'.","Pick one naming style per global and enforce it in review/CI.","Check the generated .d.ts: the missing callback signature indicates the shadowed one."],"exampleFix":"// before (.slint): callback collides with the property after translation\nexport global Player {\n    out property <int> trackChanged;   // -> trackChanged\n    callback track-changed(int);       // -> trackChanged (collides)\n}\n\n// after: unique camelCase keys\nexport global Player {\n    out property <int> current-track;\n    callback track-changed(int);       // trackChanged is now unique\n}","handlingStrategy":"validation","validationCode":"const globalObj = (instance as any)[jsGlobalName];\nfor (const cb of instance.definition().globalCallbacks(jsGlobalName) ?? []) {\n    const key = cb.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase());\n    if (typeof globalObj[key] !== 'function') {\n        throw new Error(`callback \"${cb}\" on global \"${jsGlobalName}\" is shadowed`);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Before adding a callback, check its camelCase form is not already a property/callback on that global","Apply renames globally so kebab and camel spellings never coexist","Watch the console warning during dev runs; treat it as a test failure"],"tags":["typescript","node","naming","callbacks","globals"],"backgroundTag":"duplicate-identifier-collision","analyzedSha":"3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}