refactor(components): [autocomplete] improve typings (#7381)

* refactor(components): [autocomplete] improve typings

* fix: rename
This commit is contained in:
三咲智子 2022-04-26 12:54:46 +08:00 committed by GitHub
parent 76297424cd
commit c75b20fa64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,18 @@ import { UPDATE_MODEL_EVENT } from '@element-plus/constants'
import type { ExtractPropTypes } from 'vue'
import type Autocomplete from './autocomplete.vue'
import type { Placement } from '@element-plus/components/popper'
import type { Awaitable } from '@element-plus/utils'
export type AutocompleteData = { value: string }[]
export type AutocompleteFetchSuggestionsCallback = (
data: AutocompleteData
) => void
export type AutocompleteFetchSuggestions =
| ((
queryString: string,
cb: AutocompleteFetchSuggestionsCallback
) => Awaitable<AutocompleteData> | void)
| AutocompleteData
export const autocompleteProps = buildProps({
valueKey: {
@ -37,13 +49,7 @@ export const autocompleteProps = buildProps({
default: 'bottom-start',
},
fetchSuggestions: {
type: definePropType<
| ((
queryString: string,
cb: (data: { value: string }[]) => void
) => { value: string }[] | Promise<{ value: string }[]> | void)
| { value: string }[]
>([Function, Array]),
type: definePropType<AutocompleteFetchSuggestions>([Function, Array]),
default: NOOP,
},
popperClass: {