Azordev/dasher-user

Investigate ts-check error: "Property 'x' does not exist on type 'any []'" in Delivery/index.js

Closed this issue · 3 comments

Screenshots

if (isLoading || !packageInformation?.packages[0]?.package_code) {
return <pre>Loading...</pre>
}

// @ts-ignore
clientAddress={packageInformation?.packages[0]?.client_address}
// @ts-ignore
estimatedArrival={packageInformation?.packages[0]?.estimated_arrival}

img

Checklist

  • The reason why the error occurs is known
  • Possible solutions were created
  • It was decided between fixing the error or leaving it like that

This can be solved adding proper types on JSDocs

In this cases adding @return types for useGetPackageInformation could help
image

This is an example:

/**
 * @param {packageID} Id coming from DB for certain package
 * @return { {loading: Boolean, error:Object, packageInformation: Object}}
 */
const useGetPackageInformation = packageID => {
   ...
   return {loading, error, packageInformation}
}

In this case we would need @typedef to type the return packageInformation as expected:
https://jsdoc.app/tags-typedef.html

Some references:

BUT, at the end this should be low priority, if it gets too weird is better to ignore these types

check that your tasks have the corresponding labels