Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions libs/core/src/lib/declarations/known-keys.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Get the known keys (i.e. no index signature) of T.
*
* @example
```typescript
interface Options {
key: string;
title: string;
[dataProperty: string]: string | number;
}

type KnownKeysOfOptions = KnownKeys<Options>; // 'key' | 'title';
// (vs. type KeysOfOptions = keyof Options // string | number;)
```

* Taken from https://stackoverflow.com/questions/51465182/typescript-remove-index-signature-using-mapped-types
*/
export type KnownKeys<T> = { [K in keyof T]: string extends K ? never : number extends K ? never : K } extends {
[_ in keyof T]: infer U
}
? U
: never;
4 changes: 3 additions & 1 deletion libs/core/src/lib/declarations/omit.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
import { KnownKeys } from './known-keys';

export type Omit<T, K extends keyof T> = Pick<T, Exclude<KnownKeys<T> & keyof T, K>>;
2 changes: 2 additions & 0 deletions libs/core/src/lib/declarations/public-api.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export * from './index-signature';
export * from './known-keys';
export * from './omit';
export * from './StringMap';
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@
// Licensed under the MIT License.

import { InputRendererOptions, Omit, ReactWrapperComponent } from '@angular-react/core';
import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ElementRef, EventEmitter, Input, OnDestroy, Output, QueryList, Renderer2, ViewChild } from '@angular/core';
import {
AfterContentInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ContentChild,
ElementRef,
EventEmitter,
Input,
OnDestroy,
Output,
QueryList,
Renderer2,
ViewChild,
} from '@angular/core';
import { ICommandBarItemProps, ICommandBarProps } from 'office-ui-fabric-react/lib/CommandBar';
import { IContextualMenuItem } from 'office-ui-fabric-react/lib/ContextualMenu';
import { Subscription } from 'rxjs';
import { OnChanges, TypedChanges } from '../../declarations/angular/typed-changes';
import omit from '../../utils/omit';
import { mergeItemChanges } from '../core/declarative/item-changed';
import { CommandBarItemChangedPayload, CommandBarItemDirective } from './directives/command-bar-item.directives';
import { CommandBarFarItemsDirective, CommandBarItemsDirective, CommandBarItemsDirectiveBase, CommandBarOverflowItemsDirective } from './directives/command-bar-items.directives';
import {
CommandBarFarItemsDirective,
CommandBarItemsDirective,
CommandBarItemsDirectiveBase,
CommandBarOverflowItemsDirective,
} from './directives/command-bar-items.directives';

@Component({
selector: 'fab-command-bar',
Expand Down Expand Up @@ -195,17 +214,17 @@ export class FabCommandBarComponent extends ReactWrapperComponent<ICommandBarPro
return Object.assign(
{},
sharedProperties,
iconRenderer && {
onRenderIcon: (item: IContextualMenuItem) => iconRenderer({ contextualMenuItem: item }),
} as any /* NOTE: Fix for wrong typings of `onRenderIcon` in office-ui-fabric-react */,
iconRenderer &&
({
onRenderIcon: (item: IContextualMenuItem) => iconRenderer({ contextualMenuItem: item }),
} as any) /* NOTE: Fix for wrong typings of `onRenderIcon` in office-ui-fabric-react */,
renderer &&
({ onRender: (item, dismissMenu) => renderer({ item, dismissMenu }) } as Pick<ICommandBarItemProps, 'onRender'>)
) as ICommandBarItemProps;
}
}

export interface ICommandBarItemOptions<TData = any> extends Omit<ICommandBarItemProps, 'onRender' | 'onRenderIcon'> {
readonly [propertyName: string]: any;
readonly renderIcon?: InputRendererOptions<ICommandBarItemOptionsRenderIconContext>;
readonly render?: InputRendererOptions<ICommandBarItemOptionsRenderContext>;
readonly data?: TData;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"],
"baseUrl": ".",
"skipLibCheck": true,
"paths": {
"@angular-react/*": ["libs/*"],
"@angular-react/core": ["libs/core/src/index.ts"],
Expand Down