Skip to content

Commit

Permalink
feat(Test): Add ExpectEmpty<T extends Traversable>
Browse files Browse the repository at this point in the history
  • Loading branch information
SirWrexes committed May 30, 2023
1 parent 77da038 commit 121c21e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/Test.test.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExpectTrue, ExpectNever, ExpectFalse, ExpectNotNever, ExpectEqual } from '../types'
import { ExpectTrue, ExpectNever, ExpectFalse, ExpectNotNever, ExpectEqual, ExpectEmpty } from '../types'

declare namespace ExpectTrue {
export type TwentyThree = 23
Expand Down Expand Up @@ -44,4 +44,9 @@ type __TEST__ = {
ExpectTrue<ExpectNotNever<'literal'>>,
ExpectTrue<ExpectNotNever<23>>
]
// prettier-ignore
ExpectEmpty: [
ExpectTrue<ExpectEmpty<[]>>,
ExpectFalse<ExpectEmpty<['wesh']>>
]
}
3 changes: 3 additions & 0 deletions types/Test.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-nocheck These types cause TS errors when not used in a testing context

import { Expect, ExpectTrue, ExpectFalse, ExpectExtends, ExpectValidArgs, Equal, NotEqual } from '@type-challenges/utils'
import { EmptyArray, Traversable } from './ArrayUtils'
import { IsNever } from './Conditionals'

export { Expect, ExpectTrue, ExpectFalse, ExpectExtends, ExpectValidArgs, Equal, NotEqual }
Expand All @@ -12,3 +13,5 @@ export type ExpectEqual<T, U> = Expect<Equal<T, U>>
export type ExpectNotEqual<T, U> = Not<ExpectEqual<T, U>>

export type ExpectNotExtends<T, U> = Not<ExpectExtends<T, U>>

export type ExpectEmpty<T extends Traversable> = Expect<Equal<T, EmptyArray>>

0 comments on commit 121c21e

Please sign in to comment.