From b242922ce742c20030278b778ca6c01837b39518 Mon Sep 17 00:00:00 2001 From: Jonghyeon Ko Date: Thu, 19 Oct 2023 00:49:19 +0900 Subject: [PATCH] chore: update --- packages/react-await/src/types/index.ts | 1 - packages/react-await/src/utils/assert.spec.ts | 36 ------------------- packages/react-await/src/utils/assert.ts | 19 ---------- packages/react-await/src/utils/index.ts | 1 - 4 files changed, 57 deletions(-) delete mode 100644 packages/react-await/src/utils/assert.spec.ts delete mode 100644 packages/react-await/src/utils/assert.ts diff --git a/packages/react-await/src/types/index.ts b/packages/react-await/src/types/index.ts index eed3c4b0a..c07632b17 100644 --- a/packages/react-await/src/types/index.ts +++ b/packages/react-await/src/types/index.ts @@ -1,2 +1 @@ -export type { PropsWithoutChildren } from './PropsWithoutChildren' export type { Tuple } from './Tuple' diff --git a/packages/react-await/src/utils/assert.spec.ts b/packages/react-await/src/utils/assert.spec.ts deleted file mode 100644 index f3e0c3fbc..000000000 --- a/packages/react-await/src/utils/assert.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { expectTypeOf } from 'vitest' -import { assert } from '.' - -function get(type: 'foo' | 'bar') { - switch (type) { - case 'foo': - return { - foo1: 'foo1', - foo2: 'foo2', - } as const - case 'bar': - return { - bar1: 'bar1', - bar2: 'bar2', - } as const - default: { - throw new Error('no type') - } - } -} - -describe('assert', () => { - // eslint-disable-next-line vitest/expect-expect - it('should assert condition', () => { - const data = get('foo') - assert(data.foo1 === 'foo1', 'dummy-message') - expectTypeOf(data.foo2).toMatchTypeOf() - expectTypeOf(data.bar1).not.toMatchTypeOf() - }) - - it('should throw error if given condition is not met', () => { - const assertMessage = "value should be 'paz'" - const value = 'baz' as string - expect(() => assert(value === 'paz', assertMessage)).toThrow(assertMessage) - }) -}) diff --git a/packages/react-await/src/utils/assert.ts b/packages/react-await/src/utils/assert.ts deleted file mode 100644 index ffeecf47e..000000000 --- a/packages/react-await/src/utils/assert.ts +++ /dev/null @@ -1,19 +0,0 @@ -export function assert(condition: boolean, message: string): asserts condition { - if (!condition) { - throw new Error(message) - } -} - -assert.message = { - useErrorBoundary: { - onlyInChildrenOfErrorBoundary: 'useErrorBoundary: this hook should be called in ErrorBoundary.props.children', - }, - useErrorBoundaryFallbackProps: { - onlyInFallbackOfErrorBoundary: - 'useErrorBoundaryFallbackProps: this hook should be called in ErrorBoundary.props.fallback', - }, - useErrorBoundaryGroup: { - onlyInChildrenOfErrorBoundaryGroup: - 'useErrorBoundaryGroup: this hook should be called in ErrorBoundaryGroup.props.children', - }, -} as const diff --git a/packages/react-await/src/utils/index.ts b/packages/react-await/src/utils/index.ts index 214d840aa..2f26201ab 100644 --- a/packages/react-await/src/utils/index.ts +++ b/packages/react-await/src/utils/index.ts @@ -1,3 +1,2 @@ export { hasResetKeysChanged } from './hasResetKeysChanged' export { hashKey } from './hashKey' -export { assert } from './assert'