本文整理匯總了TypeScript中vs/platform/actions/common/actions.isIMenuItem函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isIMenuItem函數的具體用法?TypeScript isIMenuItem怎麽用?TypeScript isIMenuItem使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isIMenuItem函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('special MenuId palette', function () {
disposables.push(MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: { id: 'a', title: 'Explicit' }
}));
MenuRegistry.addCommand({ id: 'b', title: 'Implicit' });
let foundA = false;
let foundB = false;
for (const item of MenuRegistry.getMenuItems(MenuId.CommandPalette)) {
if (isIMenuItem(item)) {
if (item.command.id === 'a') {
assert.equal(item.command.title, 'Explicit');
foundA = true;
}
if (item.command.id === 'b') {
assert.equal(item.command.title, 'Implicit');
foundB = true;
}
}
}
assert.equal(foundA, true);
assert.equal(foundB, true);
});
示例2: originalAppend
actions.MenuRegistry.appendMenuItem = (id: actions.MenuId, item: actions.IMenuItem | actions.ISubmenuItem): IDisposable => {
if (actions.isIMenuItem(item)) {
switch (item.command.id) {
case ToggleDevToolsAction.ID: // There appears to be no way to toggle this programmatically.
logger.debug(`Skipping unsupported menu item ${item.command.id}`);
return {
dispose: (): void => undefined,
};
}
}
return originalAppend(id, item);
};