diff --git a/packages/hooks/use-locale/index.ts b/packages/hooks/use-locale/index.ts index d022859418..0eb321d192 100644 --- a/packages/hooks/use-locale/index.ts +++ b/packages/hooks/use-locale/index.ts @@ -39,7 +39,7 @@ function translate(path, option, current) { } export const useLocale = () => { - const vm = getCurrentInstance() + const vm = getCurrentInstance()! const props = vm.props as { locale: Language } @@ -60,7 +60,7 @@ export const useLocale = () => { locale, lang, t, - } + } as LocaleContext // this could be broken if someone tries to do following: diff --git a/packages/hooks/use-migrating/index.ts b/packages/hooks/use-migrating/index.ts index 92426fdb4d..b29dc5dee0 100644 --- a/packages/hooks/use-migrating/index.ts +++ b/packages/hooks/use-migrating/index.ts @@ -4,7 +4,7 @@ import { kebabCase } from '@element-plus/utils/util' const useMigrating = function () { onMounted(() => { - const instance = getCurrentInstance() + const instance = getCurrentInstance()! if (process.env.NODE_ENV === 'production') return if (!instance.vnode) return const { props = {} } = getMigratingConfig() @@ -16,7 +16,7 @@ const useMigrating = function () { if (props[propName]) { debugWarn( 'Element Migrating', - `[${instance.proxy.$options.name}][Attribute]: ${props[propName]}` + `[${instance.proxy?.$options.name}][Attribute]: ${props[propName]}` ) } } diff --git a/packages/hooks/use-model-toggle/index.ts b/packages/hooks/use-model-toggle/index.ts index eac8d0b273..2ff6fb7eba 100644 --- a/packages/hooks/use-model-toggle/index.ts +++ b/packages/hooks/use-model-toggle/index.ts @@ -32,7 +32,7 @@ export const useModelToggle = ({ onShow, onHide, }: ModelToggleParams) => { - const { appContext, props, proxy, emit } = getCurrentInstance() + const { appContext, props, proxy, emit } = getCurrentInstance()! const hasUpdateHandler = computed(() => isFunction(props['onUpdate:modelValue']) @@ -120,7 +120,7 @@ export const useModelToggle = ({ } } - watch(() => props.modelValue, onChange) + watch(() => props.modelValue, onChange as any) if ( shouldHideWhenRouteChanges && diff --git a/packages/hooks/use-popper/use-target-events.ts b/packages/hooks/use-popper/use-target-events.ts index beefd471b5..a1f6bc6db9 100644 --- a/packages/hooks/use-popper/use-target-events.ts +++ b/packages/hooks/use-popper/use-target-events.ts @@ -21,7 +21,7 @@ export const useTargetEvents = ( onHide: Handler, onToggle: Handler ) => { - const { props } = getCurrentInstance() + const { props } = getCurrentInstance()! let triggerFocused = false @@ -67,7 +67,7 @@ export const useTargetEvents = ( const mapEvents = (t: TriggerType) => { const events = {} as PopperEvents - triggerEventsMap[t].forEach((event) => { + triggerEventsMap[t]?.forEach((event) => { events[event] = popperEventsHandler }) diff --git a/packages/hooks/use-teleport/index.ts b/packages/hooks/use-teleport/index.ts index 8458aa4b9c..75b9c6c57b 100644 --- a/packages/hooks/use-teleport/index.ts +++ b/packages/hooks/use-teleport/index.ts @@ -20,7 +20,7 @@ export default (contentRenderer: () => VNode, appendToBody: Ref) => { } } - let $el: HTMLElement = null + let $el: HTMLElement | null = null const showTeleport = () => { isTeleportVisible.value = true