fix(types): improve with strict mode (#1041)

This commit is contained in:
Benjamin Canac
2023-11-30 12:02:37 +01:00
committed by GitHub
parent 464ff0b703
commit 4a9b66aeb3
68 changed files with 266 additions and 242 deletions

View File

@@ -40,7 +40,7 @@ export const defineShortcuts = (config: ShortcutsConfig, options: ShortcutsOptio
let shortcuts: Shortcut[] = []
const chainedInputs = ref([])
const chainedInputs = ref<string[]>([])
const clearChainedInput = () => {
chainedInputs.value.splice(0, chainedInputs.value.length)
}

View File

@@ -4,7 +4,7 @@ import type { FormEvent, FormEventType, InjectedFormGroupValue } from '../types/
import { uid } from '../utils/uid'
type InputProps = {
id?: string | null
id?: string
size?: string | number | symbol
color?: string
name?: string
@@ -20,7 +20,7 @@ export const useFormGroup = (inputProps?: InputProps, config?: any) => {
const inputId = ref(inputProps?.id)
onMounted(() => {
inputId.value = inputProps?.isFieldset ? null : inputProps?.id ?? uid()
inputId.value = inputProps?.isFieldset ? undefined : inputProps?.id ?? uid()
if (formGroup) {
// Updates for="..." attribute on label if inputProps.id is provided
@@ -41,17 +41,17 @@ export const useFormGroup = (inputProps?: InputProps, config?: any) => {
}
function emitFormBlur () {
emitFormEvent('blur', formGroup?.name.value)
emitFormEvent('blur', formGroup?.name.value as string)
blurred.value = true
}
function emitFormChange () {
emitFormEvent('change', formGroup?.name.value)
emitFormEvent('change', formGroup?.name.value as string)
}
const emitFormInput = useDebounceFn(() => {
if (blurred.value || formGroup?.eagerValidation.value) {
emitFormEvent('input', formGroup?.name.value)
emitFormEvent('input', formGroup?.name.value as string)
}
}, 300)
@@ -59,7 +59,7 @@ export const useFormGroup = (inputProps?: InputProps, config?: any) => {
inputId,
name: computed(() => inputProps?.name ?? formGroup?.name.value),
size: computed(() => {
const formGroupSize = config.size[formGroup?.size.value] ? formGroup?.size.value : null
const formGroupSize = config.size[formGroup?.size.value as string] ? formGroup?.size.value : null
return inputProps?.size ?? formGroupSize ?? config?.default?.size
}),
color: computed(() => formGroup?.error?.value ? 'red' : inputProps?.color),

View File

@@ -4,7 +4,7 @@ import { useAppConfig } from '#imports'
import { mergeConfig, omit, get } from '../utils'
import type { Strategy } from '../types'
export const useUI = <T>(key, $ui?: Ref<Partial<T & { strategy?: Strategy }> | undefined>, $config?: Ref<T> | T, $wrapperClass?: Ref<string>, withAppConfig: boolean = false) => {
export const useUI = <T>(key, $ui?: Ref<Partial<T> & { strategy?: Strategy }>, $config?: Ref<T> | T, $wrapperClass?: Ref<string>, withAppConfig: boolean = false) => {
const $attrs = useAttrs()
const appConfig = useAppConfig()