diff --git a/internal/build/src/type-unsafe-stricter.json b/internal/build/src/type-unsafe-stricter.json index 0b5b4051d5..57a1f1b655 100644 --- a/internal/build/src/type-unsafe-stricter.json +++ b/internal/build/src/type-unsafe-stricter.json @@ -54,11 +54,6 @@ "packages/components/virtual-list/", "packages/components/visual-hidden/", "packages/directives/", - "packages/hooks/use-floating/", - "packages/hooks/use-forward-ref/", - "packages/hooks/use-global-config/", - "packages/hooks/use-prop/", - "packages/make-installer.ts", "packages/utils/dom/", "packages/utils/vue/" ] diff --git a/packages/element-plus/make-installer.ts b/packages/element-plus/make-installer.ts index 937640190f..fb8895e5be 100644 --- a/packages/element-plus/make-installer.ts +++ b/packages/element-plus/make-installer.ts @@ -5,6 +5,12 @@ import type { ConfigProviderContext } from '@element-plus/tokens' const INSTALLED_KEY = Symbol('INSTALLED_KEY') +declare module 'vue' { + interface App { + [INSTALLED_KEY]?: boolean + } +} + export const makeInstaller = (components: Plugin[] = []) => { const install = (app: App, options?: ConfigProviderContext) => { if (app[INSTALLED_KEY]) return diff --git a/packages/hooks/use-floating/index.ts b/packages/hooks/use-floating/index.ts index ee13df5f40..5053397a04 100644 --- a/packages/hooks/use-floating/index.ts +++ b/packages/hooks/use-floating/index.ts @@ -2,8 +2,7 @@ import { isRef, onMounted, ref, unref, watchEffect } from 'vue' import { isClient, unrefElement } from '@vueuse/core' import { isNil } from 'lodash-unified' import { arrow as arrowCore, computePosition } from '@floating-ui/dom' - -import { buildProps } from '@element-plus/utils' +import { buildProps, keysOf } from '@element-plus/utils' import type { Ref, ToRefs } from 'vue' import type { @@ -75,7 +74,7 @@ export const useFloating = ({ middleware: unref(middleware), }) - Object.keys(states).forEach((key) => { + keysOf(states).forEach((key) => { states[key].value = data[key] }) } diff --git a/packages/hooks/use-forward-ref/index.ts b/packages/hooks/use-forward-ref/index.ts index 03510bc31d..823f539f07 100644 --- a/packages/hooks/use-forward-ref/index.ts +++ b/packages/hooks/use-forward-ref/index.ts @@ -1,6 +1,6 @@ import { provide } from 'vue' -import type { InjectionKey, Ref } from 'vue' +import type { InjectionKey, ObjectDirective, Ref } from 'vue' type ForwardRefSetter = (el: T) => void @@ -21,7 +21,9 @@ export const useForwardRef = (forwardRef: Ref) => { }) } -export const useForwardRefDirective = (setForwardRef: ForwardRefSetter) => { +export const useForwardRefDirective = ( + setForwardRef: ForwardRefSetter +): ObjectDirective => { return { mounted(el) { setForwardRef(el) diff --git a/packages/hooks/use-global-config/index.ts b/packages/hooks/use-global-config/index.ts index 13e74db994..e48901001e 100644 --- a/packages/hooks/use-global-config/index.ts +++ b/packages/hooks/use-global-config/index.ts @@ -1,6 +1,7 @@ import { computed, getCurrentInstance, inject, provide, ref, unref } from 'vue' import { configProviderContextKey } from '@element-plus/tokens' import { debugWarn, keysOf } from '@element-plus/utils' + import type { MaybeRef } from '@vueuse/core' import type { App, Ref } from 'vue' import type { ConfigProviderContext } from '@element-plus/tokens' @@ -66,7 +67,7 @@ const mergeConfig = ( b: ConfigProviderContext ): ConfigProviderContext => { const keys = [...new Set([...keysOf(a), ...keysOf(b)])] - const obj = {} + const obj: Record = {} for (const key of keys) { obj[key] = b[key] ?? a[key] } diff --git a/packages/hooks/use-prop/index.ts b/packages/hooks/use-prop/index.ts index 5a0be861c8..40e5e03323 100644 --- a/packages/hooks/use-prop/index.ts +++ b/packages/hooks/use-prop/index.ts @@ -3,5 +3,5 @@ import type { ComputedRef } from 'vue' export const useProp = (name: string): ComputedRef => { const vm = getCurrentInstance()! - return computed(() => vm.proxy?.$props[name] ?? undefined) + return computed(() => (vm.proxy?.$props as any)[name] ?? undefined) }