Select to view content in your preferred language

typescript errors when upgrading to calcite 1.4.x

373
2
06-01-2023 07:53 AM
GaryB
by
New Contributor III

Hi, 

I just upgraded Calcite from version 1.3 to version 1.4 and now have 140 typescript errors where I previously had it down to only two that I couldn't resolve.  The following is an example of a very frequent new message.  What I am I doing wrong?

 let fromDatePicker = document.getElementById("form57-fltr-sel-fromdate-datepicker") as HTMLCalciteDatePickerElement

 and this is the error I am getting:

Conversion of type 'HTMLElement | null' to type 'HTMLCalciteDatePickerElement' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.  Type 'HTMLElement' is not comparable to type 'CalciteDatePicker'.

Thanks!

0 Kudos
2 Replies
GaryB
by
New Contributor III

followup - based on past experience, but not really knowing exactly why, I removed my package-lock.json file and my node_modules directory and did a 'npm install' and all the new typescript errors went away.  Might this have something to do with the note on @stencil/core version found here?

0 Kudos
coryeicher
Occasional Contributor
Are you using React by chance?

Basically your item could be undefined, and undefined isn't compatible with
the type `HTMLCalciteDatePickerElement`

Have a look here for a couple ways to address this:
https://stackoverflow.com/questions/63520680/argument-of-type-htmlelement-null-is-not-assignable-to-...
CORY EICHER
www.eichcorp.com
cory@eichcorp.com
0 Kudos