Error TS2702 on custom slider widget example

Following the tutorial at: Extending Bokeh — Bokeh 2.4.2 Documentation

I have the three files made as in the example (custom.ts, custom.py, and main.py). However when I run I get the error message below:

Compilation failed:
custom.ts:13:29 - error TS2339: Property ‘slider’ does not exist on type ‘HTMLBox’.
13 this.connect(this.model.slider.change, () => {
custom.ts:32:22 - error TS2339: Property ‘text’ does not exist on type ‘HTMLBox’.
32 }, ${this.model.text}: ${this.model.slider.value}))
custom.ts:32:42 - error TS2339: Property ‘slider’ does not exist on type ‘HTMLBox’.
32 }, ${this.model.text}: ${this.model.slider.value}))
custom.ts:53:17 - error TS2702: ‘Custom’ only refers to a type, but is being used as a namespace here.
53 this.define<Custom.Props>({

I assume the first three errors about “slider” and “text” are irrelevant and the important part is how “Custom” is being used as a namespace. However, it works according to the example in the url I posted above as well as a couple others. Googling for “error TS2702” brings up some esoteric similarities, but I ultimately can’t figure this out. Can anyone shed light into what could be going on here?

First off, you are linking to the lastet docs for version 1.2, are you actually running Bokeh 1.2 on your system? If not, you should refer to the proper docs for your version. This is true in general, but especially true for custom extensions, since BokehJS in not yet considered as stable as the Python API.

Assuming you are running the correct version: it’s hard to say much without seeing the contents of your files. So the best I can is point you at the actual file that produced the live example in the docs so that you can compare what you have to it: extensions_putting_together_ts.py (for version 1.2)

1 Like

Hey Bryan,

Using that example gets it working. I tried the live example as you suggested, first as a standalone (which worked) and then also integrated into my app with no modifications (which also worked). I was using v1.2 for what it’s worth. Haven’t been able to figure out what the difference was yet, but I no longer get the error message. Thanks for your input!

1 Like