MCPcopy
hub / github.com/vuejs/core / warnDeprecation

Function warnDeprecation

packages/runtime-core/src/compat/compatConfig.ts:438–493  ·  view source on GitHub ↗
(
  key: DeprecationTypes,
  instance: ComponentInternalInstance | null,
  ...args: any[]
)

Source from the content-addressed store, hash-verified

436}
437
438export function warnDeprecation(
439 key: DeprecationTypes,
440 instance: ComponentInternalInstance | null,
441 ...args: any[]
442): void {
443 if (!__DEV__) {
444 return
445 }
446 if (__TEST__ && !warningEnabled) {
447 return
448 }
449
450 instance = instance || getCurrentInstance()
451
452 // check user config
453 const config = getCompatConfigForKey(key, instance)
454 if (config === 'suppress-warning') {
455 return
456 }
457
458 const dupKey = key + args.join('')
459 let compId: string | number | null =
460 instance && formatComponentName(instance, instance.type)
461 if (compId === 'Anonymous' && instance) {
462 compId = instance.uid
463 }
464
465 // skip if the same warning is emitted for the same component type
466 const componentDupKey = dupKey + compId
467 if (!__TEST__ && componentDupKey in instanceWarned) {
468 return
469 }
470 instanceWarned[componentDupKey] = true
471
472 // same warning, but different component. skip the long message and just
473 // log the key and count.
474 if (!__TEST__ && dupKey in warnCount) {
475 warn(`(deprecation ${key}) (${++warnCount[dupKey] + 1})`)
476 return
477 }
478
479 warnCount[dupKey] = 0
480
481 const { message, link } = deprecationData[key]
482 warn(
483 `(deprecation ${key}) ${
484 typeof message === 'function' ? message(...args) : message
485 }${link ? `\n Details: ${link}` : ``}`,
486 )
487 if (!isCompatEnabled(key, instance, true)) {
488 console.error(
489 `^ The above deprecation's compat behavior is disabled and will likely ` +
490 `lead to runtime errors.`,
491 )
492 }
493}
494
495export type CompatConfig = Partial<

Callers 13

compileToFunctionFunction · 0.90
renderComponentRootFunction · 0.90
getFunction · 0.90
applySingletonPrototypeFunction · 0.90
installCompatMountFunction · 0.90
deepMergeDataFunction · 0.90
convertLegacyVModelPropsFunction · 0.90
getFunction · 0.90
setFunction · 0.90
getFunction · 0.90
assertCompatEnabledFunction · 0.70
softAssertCompatEnabledFunction · 0.70

Calls 7

getCurrentInstanceFunction · 0.90
formatComponentNameFunction · 0.90
warnFunction · 0.90
getCompatConfigForKeyFunction · 0.85
messageFunction · 0.85
errorMethod · 0.80
isCompatEnabledFunction · 0.70

Tested by

no test coverage detected