| b69ab31 | | | 1 | /** |
| b69ab31 | | | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| b69ab31 | | | 3 | * |
| b69ab31 | | | 4 | * This source code is licensed under the MIT license found in the |
| b69ab31 | | | 5 | * LICENSE file in the root directory of this source tree. |
| b69ab31 | | | 6 | */ |
| b69ab31 | | | 7 | |
| b69ab31 | | | 8 | export type TypeaheadResult = { |
| b69ab31 | | | 9 | /** The display text of the suggestion */ |
| b69ab31 | | | 10 | label: string; |
| b69ab31 | | | 11 | |
| b69ab31 | | | 12 | /** |
| b69ab31 | | | 13 | * Additional details to show de-emphasized next to the display name. |
| b69ab31 | | | 14 | * If provided, this is shown visually instead of the value. |
| b69ab31 | | | 15 | */ |
| b69ab31 | | | 16 | detail?: string; |
| b69ab31 | | | 17 | |
| b69ab31 | | | 18 | /** |
| b69ab31 | | | 19 | * The literal value of the suggestion, placed literally as text into the commit message. |
| b69ab31 | | | 20 | * If `detail` is not provided, value is shown de-emphasized next to the display name. |
| b69ab31 | | | 21 | */ |
| b69ab31 | | | 22 | value: string; |
| b69ab31 | | | 23 | |
| b69ab31 | | | 24 | /** |
| b69ab31 | | | 25 | * An optional image url representing this result. Usually, a user avatar. |
| b69ab31 | | | 26 | */ |
| b69ab31 | | | 27 | image?: string; |
| b69ab31 | | | 28 | }; |
| b69ab31 | | | 29 | |
| b69ab31 | | | 30 | /** |
| b69ab31 | | | 31 | * Remove particular keys from an object type: |
| b69ab31 | | | 32 | * ``` |
| b69ab31 | | | 33 | * Without<{foo: string, bar: string, baz: number}, 'bar' | 'baz'> => {foo: string} |
| b69ab31 | | | 34 | * ``` |
| b69ab31 | | | 35 | */ |
| b69ab31 | | | 36 | export type Without<T, U> = {[P in Exclude<keyof T, keyof U>]?: never}; |
| b69ab31 | | | 37 | |
| b69ab31 | | | 38 | /** |
| b69ab31 | | | 39 | * Given two object types, return a type allowing keys from either one but not both |
| b69ab31 | | | 40 | * ``` |
| b69ab31 | | | 41 | * ExclusiveOr({foo: string}, {bar: number}) -> allows {foo: 'a'}, {bar: 1}, but not {foo: 'a', bar: 1} or {} |
| b69ab31 | | | 42 | * ``` |
| b69ab31 | | | 43 | */ |
| b69ab31 | | | 44 | export type ExclusiveOr<T, U> = T | U extends object |
| b69ab31 | | | 45 | ? (Without<T, U> & U) | (Without<U, T> & T) |
| b69ab31 | | | 46 | : T | U; |