Learning TypeScript has been quite a challenge for me, especially when it comes to typing. I recently tackled a problem while working on a Vue project with TypeScript:
Parameter 'data' implicitly has an 'any' type.
Here is the code snippet:
type usersTypes = {
phone: number,
age: number
}
const usersTest = computed(() => {
const users: usersTypes = {
phone: 99999999,
age: 20
}
return users
})
const filtered = 'test'
function getUsers(data){ //Parameter 'data' implicitly has an 'any' type.
console.log('data: ', data)
console.log('users phone: ', data.users.phone) // Unsafe member access .users on an `any` value.
console.log('filter: ', data.filter) // Unsafe member access .filter on an `any` value.
}
onMounted(() => {
getUsers({
users: usersTest.value,
filter: filtered
})
})