PyCharm / IntelliJ inspection type error for Extension examples

I am using PyCharm IDE (2022.1.4) to create a custom extension and have been following this typescript example Developing JupyterLab Extensions
PyCharm shows a type error for the plugin function. It seems PyCharm shows the error when IMainMenu is added as a required or optional type. I believe the error is likely false as the example builds fine using jlpm run build
Has anyone else encountered this weird behavior and know how to resolve it?

Can you show your foll code which leads to this issue? This looks like it could be potentially caused by type-only import, or maybe PyCharm has a problem with declaration merging detection?

import {
  JupyterFrontEnd, 
  JupyterFrontEndPlugin 
} from '@jupyterlab/application'; 
 
import { ICommandPalette } from '@jupyterlab/apputils';
import { INotebookTracker, NotebookActions } from '@jupyterlab/notebook';
import { IMainMenu } from '@jupyterlab/mainmenu';
import { Menu } from '@lumino/widgets';
 
/** 
 * Initialization data for the snippetsexample extension. 
 */
const plugin: JupyterFrontEndPlugin<void> = {
  id: 'snippetsexample:plugin', 
  autoStart: true, 
  requires: [ICommandPalette, INotebookTracker, IMainMenu], 
  activate: (app: JupyterFrontEnd, palette: ICommandPalette, tracker: INotebookTracker, mainMenu: IMainMenu) => {
    console.log('JupyterLab extension myexample is activated!');
 
    const { commands } = app;
    
    commands.addCommand('openLink', {
      label: 'Documentation', 
      caption: 'Documentation', 
      execute: () => {
        const win = window.open('https://jupyterlab.readthedocs.io/en/stable/', '_blank');
        win?.focus();
      }
    });
 
    commands.addCommand('printHelloWorld', {
      label: 'Hello World!', 
      caption: 'Hello World!', 
      execute: () => {
        const current = tracker.currentWidget;
        const notebook = current!.content;
        NotebookActions.insertBelow(notebook);
        const activeCell = notebook.activeCell;
        activeCell!.model.value.text = 'print("Hello World!")';
      }
    }); 
    
    commands.addCommand('printTest', {
      label: 'Test', 
      caption: 'Test', 
      execute: () => {
        const current = tracker.currentWidget;
        const notebook = current!.content;
        NotebookActions.insertBelow(notebook);
        const activeCell = notebook.activeCell;
        activeCell!.model.value.text = 'print("Test")';
      }
    });
 
    const snippetMenu = new Menu({ commands });
    snippetMenu.title.label = 'Snippets';
    snippetMenu.addItem({command: 'openLink' }); 
    
    const printSubMenu = new Menu({ commands });
    printSubMenu.title.label = 'Print';
    printSubMenu.addItem({ command: 'printHelloWorld' });
    printSubMenu.addItem({ command: 'printTest' });
 
    snippetMenu.addItem({ type: 'submenu', submenu: printSubMenu});
    mainMenu.addMenu(snippetMenu, {rank: 300});
  }
}; 
 
export default plugin;