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