Подскажите, как убрать ошибку, которая нависла над этой строчкой
selected.value.push(el)
Argument of type 'any' is not assignable to parameter of type 'never'.Vetur(2345)
const el: any
const el: any
?
Только начал разбираться в TypeScript
<script lang="ts">
import { defineComponent, useStore, ref } from '@nuxtjs/composition-api'
export default defineComponent({
setup() {
const parentCategories = ref([])
const categories = ref([])
const selected = ref([])
const store = useStore()
categories.value = store.getters.GET_CATEGORIES
parentCategories.value = getParentCategories()
const changeCategory = (id: Number) => {
const el: any = categories.value.find((el: any) => el.id === id)
if (!el) return false
const children = categories.value.filter(
(item: any) => item.parentId === el.id
)
if (children.length > 0) {
parentCategories.value = categories.value.filter(
(item: any) => item.parentId === el.id
)
selected.value.push(el)
} else {
store.dispatch('SET_CATEGORY_MODAL_SELECTED', el)
closeModal()
}
}
const prevCategory = (id: Number) => {
const categorySelected: any = categories.value.find(
(el: any) => el.id === id
)
if (!categorySelected) return false
if (categorySelected.parentId === 0) {
parentCategories.value = getParentCategories()
selected.value = []
} else {
parentCategories.value = categories.value.filter(
(item: any) => item.id === categorySelected.parentId
)
}
}
const closeModal = () => {
store.dispatch('OPEN_CATEGORY_MODAL', false)
}
function getParentCategories() {
return categories.value.filter((item: any) => item.parentId === 0)
}
return {
closeModal,
changeCategory,
prevCategory,
selected,
parentCategories,
}
},
})
</script>