feat(warn): infer anonymous component named based on resolve name

This commit is contained in:
Evan You 2020-04-20 16:17:29 -04:00
parent 0278992f78
commit dece6102aa

View File

@ -1,5 +1,10 @@
import { currentRenderingInstance } from '../componentRenderUtils' import { currentRenderingInstance } from '../componentRenderUtils'
import { currentInstance, Component, FunctionalComponent } from '../component' import {
currentInstance,
Component,
FunctionalComponent,
ComponentOptions
} from '../component'
import { Directive } from '../directives' import { Directive } from '../directives'
import { import {
camelize, camelize,
@ -69,8 +74,15 @@ function resolveAsset(
res = self res = self
} }
} }
if (__DEV__ && warnMissing && !res) { if (__DEV__) {
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`) if (res) {
// in dev, infer anonymous component's name based on registered name
if (type === COMPONENTS && !(res as Component).name) {
;(res as ComponentOptions).name = name
}
} else if (warnMissing) {
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`)
}
} }
return res return res
} else if (__DEV__) { } else if (__DEV__) {