Error updating Custom (Save) Tool from older version of Bokeh

I’m working on updating some old code (from Bokeh 1.0.3/Python 3.6) I inherited that creates a custom save tool on a webpage using Bokeh server. I want it to work with Bokeh 2.4.3/Python 3.10.

I’ve made some progress but I get this error “TS2339: Property ‘save’ does not exist on type ‘PlotView’” when I run the code through the (new) Bokeh server and the code failed to compile.

There aren’t many examples online but I’m following a Typescript example I found.

Code snippet (customsave.ts):

import {ActionTool, ActionToolView} from "models/tools/actions/action_tool"
import * as p from "core/properties"

export class CustomSaveToolView extends ActionToolView {
  model: CustomSaveTool

  doit(): void {
    if (this.model.callback != null)


export namespace CustomSaveTool {
  export type Attrs = p.AttrsOf<Props>

  export type Props = ActionTool.Props & {
    save_name: p.Property<any>
    base_name: p.Property<any>
    callback: p.Property< any | null>

export interface CustomSaveTool extends CustomSaveTool.Attrs {}

export class CustomSaveTool extends ActionTool {
  properties: CustomSaveTool.Props

  constructor(attrs?: Partial<CustomSaveTool.Attrs>) {

  static initClass(): void {
    this.prototype.type = "CustomSaveTool";
    this.prototype.default_view = CustomSaveToolView;

      save_name:    [p.Any      ],
      base_name:    [p.Any      ],
      callback:     [p.Any      ],

  tool_name = "Save"
  icon = "bk-tool-icon-save"

CustomSaveTool takes a string (base_name) and a callback and should open up a Save file dialog using save_name, a string modified by the callback. It acts like the View no longer has a save method/function even though the few examples I’ve found online are written the same way.

Any help in figuring this out would be great.

UPDATE (20221004):
So I never got any response to my request for help but I was able to figure out a solution.

It turns out the original TypeScript files came from the BokehJs library files in Bokeh 1.0.3 and were customized from that.

So I copied the relevant file (/bokehjs/src/lib/models/tools/actions/save_tools.ts), renamed it (customsave.ts), and used it as the base file to modify to update the code. It seems to work well enough.

Thanks to the original coder who left good comments in the code. Always write good comments.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.