mirror of
https://github.com/desktop/desktop
synced 2024-11-05 20:49:32 +00:00
Exhaustive type checking
This commit is contained in:
parent
1d6fb6d8e5
commit
e839946092
1 changed files with 3 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
import { assertNever } from '../lib/fatal-error'
|
||||
|
||||
/** A type union of all possible types of menu items */
|
||||
export type MenuItem = IMenuItem | ISubmenuItem | ISeparatorMenuItem | ICheckboxMenuItem | IRadioMenuItem
|
||||
|
||||
|
@ -142,7 +144,7 @@ function menuItemFromElectronMenuItem(menuItem: Electron.MenuItem): MenuItem {
|
|||
case 'radio':
|
||||
return { id, type: 'radio', label, enabled, visible, accelerator, checked }
|
||||
default:
|
||||
throw new Error(`Unknown menu item type ${menuItem.type}`)
|
||||
return assertNever(menuItem.type, `Unknown menu item type ${menuItem.type}`)
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue