I’ve had an extension to JupyterLab which has worked well for about a year, but recently typescript started throwing compilation errors. I have an Editor which extends Widget, and a Menu which extends Widget, and both are now non-compliant due to fields which have been added to the underlying Widget class which are not implemented in our Extension. The properties are _hiddenMode (private), _startTimer(private) and hiddenMode (public).
I tried doing the obvious thing of simply including declarations for these, with the appropriate type (Widget.HiddenMode), but tsc then complained it couldn’t find Widget.HiddenMode, even though it was plainly declared in the Widget class file.
Nothing worked, until eventually I put in a comment which told tsc to ignore the error, which is obviously not a great solution.
So my question is, how do I implement these fields in a way that will make tsc happy? In particular, how do I find the appropriate types for these fields, and which files should I import and include?
Thanks in advance for any help and advice
A search for “hidden” in the closed prs on lumino checks out.
Most likely you have two (or more) versions of @lumino/widgets
in your node_modules
that are being found when you try to build, one from before that PR, and one from after.
recently typescript started throwing compilation errors.
hopefully, you have been checking in your yarn.lock
. you should be able to walk back to when the problem started, and you’ll see multiple entries of @lumino/widget
.
You’ll then want to take a look at your version ranges in package.json
for the various @lumino
and @jupyterlab
packages to ensure they line up with the upstream for the version of jupyterlab that you are building against. usually matching the notation used there is enough, but you might need to add resolutions
as well.
find the appropriate types for these fields,
We love to rag on how big and verbose node_modules
is, but all of the source of everything you’re looking at is in your local node_modules
and is directly navigable. grep -R HiddenMode node_modules
can tear through it really quickly.