Getting a strange error when trying to add a new menu item to the main menu bar?

Hi there, I am creating an extension that adds a button and main menu item. In my Jupyterlab extension, my activate function looks like this:

async function activate(
app: JupyterFrontEnd,
mainMenu: IMainMenu,
) {
// Adds a button/widget
app.docRegistry.addWidgetExtension(‘Notebook’, new ButtonExtension());

// Adds a new top level menu
const menu = new Menu({ commands: app.commands });
menu.title.label = ‘New Menu Item’;
mainMenu.addMenu(menu, { rank: 50 });
}

However, when launching my jupyterlab environment it seems the button is being registered and added but the main menu item has an error that the addMenu function does not exist:

But from looking at the example extensions as well as the documentation here, the function does exist… why can’t I call it? :confused:

I ended up separating the activate function into two with two separate files for the button/widget and the menu bar item and it worked.