{"record":{"id":"edbdcea1735d3d06","repo":"twbs/bootstrap","slug":"no-method-named-config-edbdce","errorCode":null,"errorMessage":"No method named \"${config}\"","messagePattern":"No method named \"(.+?)\"","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"js/src/carousel.js","lineNumber":419,"sourceCode":"      return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT\n    }\n\n    return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT\n  }\n\n  // Static\n  static jQueryInterface(config) {\n    return this.each(function () {\n      const data = Carousel.getOrCreateInstance(this, config)\n\n      if (typeof config === 'number') {\n        data.to(config)\n        return\n      }\n\n      if (typeof config === 'string') {\n        if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {\n          throw new TypeError(`No method named \"${config}\"`)\n        }\n\n        data[config]()\n      }\n    })\n  }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) {\n  const target = SelectorEngine.getElementFromSelector(this)\n\n  if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {\n    return\n  }","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/twbs/bootstrap/blob/6177d5f8497f2c08f9874f5221fd17ce5acd2ad7/js/src/carousel.js#L401-L437","documentation":"Carousel's jQueryInterface treats a numeric argument specially — data.to(config) jumps to that slide — and only string arguments go through method dispatch, which rejects names that do not resolve on the instance, start with '_', or equal 'constructor'. Public methods are next, nextWhenVisible, prev, pause, cycle, to and dispose. A slide number sent as a string ('2') bypasses the numeric path, fails the lookup, and throws.","triggerScenarios":"$('#carousel').carousel('2') — the slide index as a string instead of the number 2; $('#carousel').carousel('goTo', 2); $('#carousel').carousel('slide') (a common guess, not a v5 method); $('#carousel').carousel('_config') or 'constructor'.","commonSituations":"Slide indexes arriving from templates/routes as strings; code migrated from v4 where the jQuery API differed; automated tests exercising the jQuery surface with typo'd or guessed method names.","solutions":["To jump to a slide, pass a number: $('#carousel').carousel(2) — it maps to data.to(2).","Use only public methods: next, nextWhenVisible, prev, pause, cycle, to, dispose.","Convert string indexes before the call: Number(index) if !Number.isNaN(Number(index)).","For dynamic names, check typeof instance[name] === 'function' && !name.startsWith('_') && name !== 'constructor' first."],"exampleFix":"// before\n$('#carousel').carousel('2')       // string → method lookup → TypeError\n$('#carousel').carousel('goTo', 2) // no such method\n\n// after\n$('#carousel').carousel(2)         // number → data.to(2)\n$('#carousel').carousel('next')    // next|nextWhenVisible|prev|pause|cycle|to|dispose","handlingStrategy":"validation","validationCode":"function callCarouselMethod(element, arg) {\n  const instance = bootstrap.Carousel.getOrCreateInstance(element)\n  if (typeof arg === 'number') { // numeric shortcut → data.to(arg)\n    instance.to(arg)\n    return\n  }\n  const callable = typeof instance[arg] === 'function' &&\n    !arg.startsWith('_') && arg !== 'constructor'\n  if (callable) instance[arg]()\n  else console.warn(`Carousel: ignoring unknown method \"${arg}\"`)\n}","typeGuard":"const CAROUSEL_METHODS = ['next', 'nextWhenVisible', 'prev', 'pause', 'cycle', 'to', 'dispose'] as const\ntype CarouselMethod = (typeof CAROUSEL_METHODS)[number]\nconst isCarouselMethod = (m: string): m is CarouselMethod =>\n  (CAROUSEL_METHODS as readonly string[]).includes(m)","tryCatchPattern":"try {\n  $('#carousel').carousel(method)\n} catch (err) {\n  if (err instanceof TypeError && err.message.startsWith('No method named')) {\n    console.warn(`Carousel: unknown method \"${method}\"`)\n  } else {\n    throw err\n  }\n}","preventionTips":["Pass slide indexes as numbers — $('#carousel').carousel(2), never '2'.","Whitelist dynamic names against the seven public methods.","Convert template/route strings with Number() before the call.","Prefer the vanilla API for dynamic dispatch: instance.to(n)."],"tags":["bootstrap","carousel","jquery","typeerror","method-dispatch"],"backgroundTag":"invalid-method-name","analyzedSha":"6177d5f8497f2c08f9874f5221fd17ce5acd2ad7","analyzedAt":"2026-08-22T03:20:03.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}