Fix ICommandBarItemOptions type (again)
This commit is contained in:
Родитель
6d99ee66c0
Коммит
59ca73a69a
|
@ -1,4 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
/**
|
||||
* An object with a `string`-based index signature.
|
||||
*/
|
||||
export type StringMap<T = any> = { [index: string]: T };
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
/**
|
||||
* Get the known keys (i.e. no index signature) of T.
|
||||
*
|
||||
|
@ -15,8 +18,6 @@ type KnownKeysOfOptions = KnownKeys<Options>; // 'key' | 'title';
|
|||
|
||||
* 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;
|
||||
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;
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { KnownKeys } from './known-keys';
|
||||
|
||||
/**
|
||||
* Inverse of `Pick<T, K>`.
|
||||
*/
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<KnownKeys<T> & keyof T, K>>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { InputRendererOptions, Omit, ReactWrapperComponent } from '@angular-react/core';
|
||||
import { InputRendererOptions, ReactWrapperComponent } from '@angular-react/core';
|
||||
import {
|
||||
AfterContentInit,
|
||||
ChangeDetectionStrategy,
|
||||
|
@ -224,7 +224,10 @@ export class FabCommandBarComponent extends ReactWrapperComponent<ICommandBarPro
|
|||
}
|
||||
}
|
||||
|
||||
export interface ICommandBarItemOptions<TData = any> extends Omit<ICommandBarItemProps, 'onRender' | 'onRenderIcon'> {
|
||||
// Not using `Omit` here since it confused the TypeScript compiler and it just showed the properties listed here (`renderIcon`, `render` and `data`).
|
||||
// The type here is just `Omit` without the generics though.
|
||||
export interface ICommandBarItemOptions<TData = any>
|
||||
extends Pick<ICommandBarItemProps, Exclude<KnownKeys<ICommandBarItemProps>, 'onRender' | 'onRenderIcon'>> {
|
||||
readonly renderIcon?: InputRendererOptions<ICommandBarItemOptionsRenderIconContext>;
|
||||
readonly render?: InputRendererOptions<ICommandBarItemOptionsRenderContext>;
|
||||
readonly data?: TData;
|
||||
|
|
Загрузка…
Ссылка в новой задаче