Skip to content

Commit ed15a3c

Browse files
authored
Merge pull request #21 from Microsoft/fix-intellisense-missing-keys
Fix intellisense missing keys
2 parents c5c6e55 + e584058 commit ed15a3c

File tree

5 files changed

+53
-7
lines changed

5 files changed

+53
-7
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Get the known keys (i.e. no index signature) of T.
3+
*
4+
* @example
5+
```typescript
6+
interface Options {
7+
key: string;
8+
title: string;
9+
[dataProperty: string]: string | number;
10+
}
11+
12+
type KnownKeysOfOptions = KnownKeys<Options>; // 'key' | 'title';
13+
// (vs. type KeysOfOptions = keyof Options // string | number;)
14+
```
15+
16+
* Taken from https://stackoverflow.com/questions/51465182/typescript-remove-index-signature-using-mapped-types
17+
*/
18+
export type KnownKeys<T> = { [K in keyof T]: string extends K ? never : number extends K ? never : K } extends {
19+
[_ in keyof T]: infer U
20+
}
21+
? U
22+
: never;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
4+
import { KnownKeys } from './known-keys';
5+
6+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<KnownKeys<T> & keyof T, K>>;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
export * from './index-signature';
5+
export * from './known-keys';
46
export * from './omit';
57
export * from './StringMap';

libs/fabric/src/lib/components/command-bar/command-bar.component.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,34 @@
22
// Licensed under the MIT License.
33

44
import { InputRendererOptions, Omit, ReactWrapperComponent } from '@angular-react/core';
5-
import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ElementRef, EventEmitter, Input, OnDestroy, Output, QueryList, Renderer2, ViewChild } from '@angular/core';
5+
import {
6+
AfterContentInit,
7+
ChangeDetectionStrategy,
8+
ChangeDetectorRef,
9+
Component,
10+
ContentChild,
11+
ElementRef,
12+
EventEmitter,
13+
Input,
14+
OnDestroy,
15+
Output,
16+
QueryList,
17+
Renderer2,
18+
ViewChild,
19+
} from '@angular/core';
620
import { ICommandBarItemProps, ICommandBarProps } from 'office-ui-fabric-react/lib/CommandBar';
721
import { IContextualMenuItem } from 'office-ui-fabric-react/lib/ContextualMenu';
822
import { Subscription } from 'rxjs';
923
import { OnChanges, TypedChanges } from '../../declarations/angular/typed-changes';
1024
import omit from '../../utils/omit';
1125
import { mergeItemChanges } from '../core/declarative/item-changed';
1226
import { CommandBarItemChangedPayload, CommandBarItemDirective } from './directives/command-bar-item.directives';
13-
import { CommandBarFarItemsDirective, CommandBarItemsDirective, CommandBarItemsDirectiveBase, CommandBarOverflowItemsDirective } from './directives/command-bar-items.directives';
27+
import {
28+
CommandBarFarItemsDirective,
29+
CommandBarItemsDirective,
30+
CommandBarItemsDirectiveBase,
31+
CommandBarOverflowItemsDirective,
32+
} from './directives/command-bar-items.directives';
1433

1534
@Component({
1635
selector: 'fab-command-bar',
@@ -195,17 +214,17 @@ export class FabCommandBarComponent extends ReactWrapperComponent<ICommandBarPro
195214
return Object.assign(
196215
{},
197216
sharedProperties,
198-
iconRenderer && {
199-
onRenderIcon: (item: IContextualMenuItem) => iconRenderer({ contextualMenuItem: item }),
200-
} as any /* NOTE: Fix for wrong typings of `onRenderIcon` in office-ui-fabric-react */,
217+
iconRenderer &&
218+
({
219+
onRenderIcon: (item: IContextualMenuItem) => iconRenderer({ contextualMenuItem: item }),
220+
} as any) /* NOTE: Fix for wrong typings of `onRenderIcon` in office-ui-fabric-react */,
201221
renderer &&
202222
({ onRender: (item, dismissMenu) => renderer({ item, dismissMenu }) } as Pick<ICommandBarItemProps, 'onRender'>)
203223
) as ICommandBarItemProps;
204224
}
205225
}
206226

207227
export interface ICommandBarItemOptions<TData = any> extends Omit<ICommandBarItemProps, 'onRender' | 'onRenderIcon'> {
208-
readonly [propertyName: string]: any;
209228
readonly renderIcon?: InputRendererOptions<ICommandBarItemOptionsRenderIconContext>;
210229
readonly render?: InputRendererOptions<ICommandBarItemOptionsRenderContext>;
211230
readonly data?: TData;

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"typeRoots": ["node_modules/@types"],
1111
"lib": ["es2017", "dom"],
1212
"baseUrl": ".",
13+
"skipLibCheck": true,
1314
"paths": {
1415
"@angular-react/*": ["libs/*"],
1516
"@angular-react/core": ["libs/core/src/index.ts"],

0 commit comments

Comments
 (0)