yt-project / widgyts

Widgets for yt
https://widgyts.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
10 stars 10 forks source link

editable install error #104

Closed chrishavlin closed 1 week ago

chrishavlin commented 1 week ago

Trying to set up a dev environment yields a deprecation warning with the current project setup.

Running pip install -e . yields a long error message, the relevant portion of which can be seen with

$ jlpm run build

yarn run v1.21.1
$ jlpm run build:lib && jlpm run build:labextension:dev
$ tsc
src/fullscreen.ts:93:3 - error TS2425: Class 'DOMWidgetView' defines instance member property 'events', but extended class 'FullscreenButtonView' defines it as instance member function.

93   events(): { [e: string]: string } {
     ~~~~~~

Found 1 error in src/fullscreen.ts:93

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

environment

Following the github build action, from a fresh conda environment with python 3.10 I did:

conda install nodejs
python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9
jlpm
pip install -e . 

everything up to the pip install ran fine. Also, pip install . works! it's only the editable install that's having an issue?

potential fix

The following fixes my compilation issue and things run OK,

diff --git a/src/fullscreen.ts b/src/fullscreen.ts
index dbf274c..79be291 100644
--- a/src/fullscreen.ts
+++ b/src/fullscreen.ts
@@ -89,11 +89,7 @@ export class FullscreenButtonView extends DOMWidgetView {
   /**
    * Dictionary of events and handlers
    */
-  events(): { [e: string]: string } {
-    // TODO: return typing not needed in Typescript later than 1.8.x
-    // See http://stackoverflow.com/questions/22077023/why-cant-i-indirectly-return-an-object-literal-to-satisfy-an-index-signature-re and https://github.com/Microsoft/TypeScript/pull/7029
-    return { click: '_handle_click' };
-  }
+  events: { [e: string]: string } = { click: '_handle_click' };

but maybe I'm missing something in my environment setup?

matthewturk commented 1 week ago

This fix looks fine to me!

chrishavlin commented 1 week ago

ok, i'll submit the fix then