title: Create Electron Menu in TypeScript?
body: <p>Just started a simple Electron app using TypeScript and I'm trying to get my custom menu setup. I followed the example in JS, but the line</p>
  <p><code>menu = Menu.buildFromTemplate(template);</code> fails to compile with the error:</p>
  <p><code>main.ts(109,35): error TS2345: Argument of type '({ label: string; submenu: ({ role: string; } | { type: string; })[]; } | { role: string; submenu...' is not assignable to parameter of type 'MenuItemConstructorOptions[]'.</code></p>
  <p>I must be missing something. Couldn't find a type &quot;MenuItemConstructorOptions anywhere (but I might have looked in the wrong places). My full code for <strong>main.ts</strong>:</p>
  <pre><code>import { app, BrowserWindow, screen, Menu } from 'electron';
  import * as path from 'path';
  
  let win, menu;
  
  function createWindow() {
      const electronScreen = screen;
      const size = electronScreen.getPrimaryDisplay().workAreaSize;
  
      win = new BrowserWindow({
          x: 0,
          y: 0,
          width: size.width,
          height: size.height
      });
  
      // and load the index.html of the app.
      win.loadURL('file://' + __dirname + '/index.html');
      win.webContents.openDevTools();
      win.on('closed', () =&gt; {
          win = null;
      });
  }
  
  function createMenu() {
      const template = [{
              label: 'Edit',
              submenu: [
                  { role: 'undo' },
                  { role: 'redo' },
                  { type: 'separator' },
                  { role: 'cut' },
                  { role: 'copy' },
                  { role: 'paste' },
                  { role: 'pasteandmatchstyle' },
                  { role: 'delete' },
                  { role: 'selectall' }
              ]
          },
          {
              label: 'View',
              submenu: [
                  { role: 'reload' },
                  { role: 'forcereload' },
                  { role: 'toggledevtools' },
                  { type: 'separator' },
                  { role: 'resetzoom' },
                  { role: 'zoomin' },
                  { role: 'zoomout' },
                  { type: 'separator' },
                  { role: 'togglefullscreen' }
              ]
          },
          { role: 'window', submenu: [{ role: 'minimize' }, { role: 'close' }] },
          {
              role: 'help',
              submenu: [{
                  label: 'Learn More',
                  click() {                           require('electron').shell.openExternal('https://electron.atom.io');
                  }
              }]
          }
      ];
      menu = Menu.buildFromTemplate(template);
      Menu.setApplicationMenu(menu);
  }
  
  try {
      app.on('ready', function() {
          createWindow();
          createMenu();
      });
      app.on('window-all-closed', () =&gt; {
          if (process.platform !== 'darwin') {
              app.quit();
          }
      });
  
      app.on('activate', () =&gt; {
          if (win === null) {
              createWindow();
          }
      });
  } catch (e) {
      throw e;
  }
  </code></pre>