{"record":{"id":"dceffbe772ace052","repo":"swc-project/swc","slug":"duplicated-element-elements-j-key","errorCode":null,"errorMessage":"Duplicated element (${elements[j].key})","messagePattern":"Duplicated element \\((.+?)\\)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs","lineNumber":165,"sourceCode":"            for (var j = 0; j < newExtras.length; j++) _addElementPlacement(newExtras[j], placements);\n            extras.push.apply(extras, newExtras);\n        }\n    }\n\n    return { element: element, finishers: finishers, extras: extras };\n}\nfunction _decorateConstructor(elements, decorators) {\n    var finishers = [];\n    for (var i = decorators.length - 1; i >= 0; i--) {\n        var obj = _fromClassDescriptor(elements);\n        var elementsAndFinisher = _toClassDescriptor((0, decorators[i])(obj) || obj);\n        if (elementsAndFinisher.finisher !== undefined) finishers.push(elementsAndFinisher.finisher);\n        if (elementsAndFinisher.elements !== undefined) {\n            elements = elementsAndFinisher.elements;\n            for (var j = 0; j < elements.length - 1; j++) {\n                for (var k = j + 1; k < elements.length; k++) {\n                    if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) {\n                        throw new TypeError(\"Duplicated element (\" + elements[j].key + \")\");\n                    }\n                }\n            }\n        }\n    }\n\n    return { elements: elements, finishers: finishers };\n}\nfunction _fromElementDescriptor(element) {\n    var obj = { kind: element.kind, key: element.key, placement: element.placement, descriptor: element.descriptor };\n    var desc = { value: \"Descriptor\", configurable: true };\n    Object.defineProperty(obj, Symbol.toStringTag, desc);\n    if (element.kind === \"field\") obj.initializer = element.initializer;\n\n    return obj;\n}\nfunction _toElementDescriptors(elementObjects) {\n    if (elementObjects === undefined) return;","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs#L147-L183","documentation":"The typescript wasm binding (used by @swc/wasm-typescript) funnels every operation through try_with_json_handler, which collects diagnostics via a Handler and expects the operation to succeed whenever no errors were emitted. Ok(ret.expect(\"it should not fail without emitting errors to handler\")) panics when the underlying operation returns Err without reporting anything to the handler - an internal contract violation, since well-formed failures are supposed to arrive as JSON diagnostics.","triggerScenarios":"Calling the binding's transform/strip entry points with an input that drives swc_ts_fast_strip (or the wrapped operation) down an Err path that never emits to the handler - e.g. an internal bail on unsupported syntax constructs or resource exhaustion inside the wasm module.","commonSituations":"Using @swc/wasm-typescript in browser-based playground/build tools and feeding unusual TypeScript (decorators + satisfy chains, extremely deep nesting) that trips an unlogged failure; version skew between the wasm binding and the rust core; memory pressure in wasm runtimes turning an allocation failure into a plain Err.","solutions":["Capture the JS exception (the wasm panic crosses the boundary as a rejected Error) and extract the input that caused it; verify it parses with the same binding version in Node to isolate runtime factors.","Upgrade @swc/wasm-typescript (and any @swc/core wrappers) to the latest patch - handler-emission gaps are fixed as bugs.","File an swc issue with the minimal TypeScript input and binding version.","Guard deployments with a fallback transformer for inputs that trigger the panic."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const out = stripTypes(source, opts);\n} catch (e) {\n  const msg = String(e?.message ?? e);\n  if (msg.includes('it should not fail without emitting errors to handler')) {\n    // internal invariant panic: no diagnostics were produced\n    reportToTracker({ kind: 'swc-wasm-invariant', source, version });\n    return fallbackStrip(source);\n  }\n  throw e;\n}","preventionTips":["Treat this message as a library bug signal - never as a syntax problem in user code.","Retain the failing input and binding version in error reports.","Wrap wasm transform calls so one bad file cannot abort a whole batch."],"tags":["swc","wasm","typescript","internal-error","invariant","panic"],"backgroundTag":"wasm-binding-panic","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}