Skip to content

Commit

Permalink
feat: 🔖 0.6.1 - Fix IsArray and IsNonArray spelling to match rest of …
Browse files Browse the repository at this point in the history
…types, add test coverage to IsNonArray
  • Loading branch information
CRBroughton committed May 9, 2024
1 parent c5854a6 commit 1db64ef
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @crbroughton/ts-test-utils

## 0.6.1

### Patch Changes

- Fix IsArray and IsNonArray spelling to match rest of types, add test coverage to IsNonArray

## 0.6.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export type Assignable<Actual, Assigned extends Actual> = Assigned extends Actua

export type Extends<Actual, Extension> = Extension extends Actual ? true : false

export type isArray<Actual> = Actual extends any[] ? true : false
export type IsArray<Actual> = Actual extends any[] ? true : false

export type isNonArray<Actual> = isArray<Actual> extends true ? false : true
export type IsNonArray<Actual> = IsArray<Actual> extends true ? false : true

export type Length<Actual extends readonly any[]> = Actual['length']

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@crbroughton/ts-test-utils",
"type": "module",
"version": "0.6.0",
"version": "0.6.1",
"description": "A collection of testing helper types",
"author": "Craig R Broughton",
"license": "MIT",
Expand Down
15 changes: 15 additions & 0 deletions tests/IsNonArray.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable unused-imports/no-unused-vars */
import { describe, it } from 'bun:test'
import type { Expect, IsNonArray } from '../index'

describe('IsNonArray tests', () => {
it('Passes the IsNonArray test when the type is not an array', () => {
type Result = Expect<IsNonArray<{ id: number }>>
// ^?
})
it('Failed the IsNonArray test when the type is an array', () => {
// @ts-expect-error - Fails the exclusion
type Result = Expect<IsNonArray<{ id: string }[]>>
// ^?
})
})
6 changes: 3 additions & 3 deletions tests/isArray.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable unused-imports/no-unused-vars */
import { describe, it } from 'bun:test'
import type { Expect, isArray } from '../index'
import type { Expect, IsArray } from '../index'

describe('isArray tests', () => {
it('Passes the isArray test when the type is an array', () => {
type Result = Expect<isArray<{ id: number }[]>>
type Result = Expect<IsArray<{ id: number }[]>>
// ^?
})
it('Failed the isArray test when the type is not an array', () => {
// @ts-expect-error - Fails the exclusion
type Result = Expect<isArray<{ id: string }>>
type Result = Expect<IsArray<{ id: string }>>
// ^?
})
})

0 comments on commit 1db64ef

Please sign in to comment.