From 5a5c0ce426bb4610ef93046881a918329aab8df7 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Tue, 10 May 2022 05:13:24 -0700 Subject: [PATCH] Export typeUtils from flipper-common Reviewed By: passy Differential Revision: D36098166 fbshipit-source-id: 0f3da1d17da8ff6d08bc05abe73f9657df3bc3b8 --- desktop/flipper-common/src/index.tsx | 1 + desktop/flipper-common/src/utils/typeUtils.tsx | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 desktop/flipper-common/src/utils/typeUtils.tsx diff --git a/desktop/flipper-common/src/index.tsx b/desktop/flipper-common/src/index.tsx index e014558f9..b63073455 100644 --- a/desktop/flipper-common/src/index.tsx +++ b/desktop/flipper-common/src/index.tsx @@ -49,6 +49,7 @@ export { deserializeRemoteError, } from './utils/errors'; export {createControlledPromise} from './utils/controlledPromise'; +export * from './utils/typeUtils'; export * from './GK'; export * from './clientUtils'; export * from './settings'; diff --git a/desktop/flipper-common/src/utils/typeUtils.tsx b/desktop/flipper-common/src/utils/typeUtils.tsx new file mode 100644 index 000000000..ef3ad766f --- /dev/null +++ b/desktop/flipper-common/src/utils/typeUtils.tsx @@ -0,0 +1,14 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +// Typescript doesn't know Array.filter(Boolean) won't contain nulls. +// So use Array.filter(notNull) instead. +export function notNull(x: T | null | undefined): x is T { + return x !== null && x !== undefined; +}