From 2d3bf68c0f42bd91de7c4c34e3ad573e13739a07 Mon Sep 17 00:00:00 2001 From: Olly Hodgson Date: Tue, 28 May 2024 16:50:51 -0700 Subject: [PATCH] Brings the flow types up to date --- src/tiny-invariant.flow.js | 12 ------------ src/tiny-invariant.js.flow | 8 ++++++++ 2 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 src/tiny-invariant.flow.js create mode 100644 src/tiny-invariant.js.flow diff --git a/src/tiny-invariant.flow.js b/src/tiny-invariant.flow.js deleted file mode 100644 index 0f534cc..0000000 --- a/src/tiny-invariant.flow.js +++ /dev/null @@ -1,12 +0,0 @@ -// @flow -// This file is not actually executed -// It is just used by flow for typing - -const prefix: string = 'Invariant failed'; - -export default function invariant(condition: mixed, message?: string | (() => string)) { - if (condition) { - return; - } - throw new Error(`${prefix}: ${message || ''}`); -} diff --git a/src/tiny-invariant.js.flow b/src/tiny-invariant.js.flow new file mode 100644 index 0000000..fc577df --- /dev/null +++ b/src/tiny-invariant.js.flow @@ -0,0 +1,8 @@ +// @flow + +declare module "tiny-invariant" { + declare export default function invariant( + condition: mixed, + message?: string | (() => string), + ): boolean; +}