mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-27 02:01:15 +08:00
fix(hooks): type error (#7941)
This commit is contained in:
parent
652333e395
commit
37e2bfaee4
@ -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/"
|
||||
]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { provide } from 'vue'
|
||||
|
||||
import type { InjectionKey, Ref } from 'vue'
|
||||
import type { InjectionKey, ObjectDirective, Ref } from 'vue'
|
||||
|
||||
type ForwardRefSetter = <T>(el: T) => void
|
||||
|
||||
@ -21,7 +21,9 @@ export const useForwardRef = <T>(forwardRef: Ref<T | null>) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const useForwardRefDirective = (setForwardRef: ForwardRefSetter) => {
|
||||
export const useForwardRefDirective = (
|
||||
setForwardRef: ForwardRefSetter
|
||||
): ObjectDirective => {
|
||||
return {
|
||||
mounted(el) {
|
||||
setForwardRef(el)
|
||||
|
@ -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<string, any> = {}
|
||||
for (const key of keys) {
|
||||
obj[key] = b[key] ?? a[key]
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ import type { ComputedRef } from 'vue'
|
||||
|
||||
export const useProp = <T>(name: string): ComputedRef<T | undefined> => {
|
||||
const vm = getCurrentInstance()!
|
||||
return computed(() => vm.proxy?.$props[name] ?? undefined)
|
||||
return computed(() => (vm.proxy?.$props as any)[name] ?? undefined)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user