Skip to content

Commit

Permalink
refactor: move types
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Oct 6, 2023
1 parent 8f0e3e2 commit bfeefe0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion type-plus/ts/equal/equal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsAny } from '../any/is_any.js'
import type { IsNever } from '../never/is_never.js'
import type { IsObject } from '../object/object_type.js'
import type { IsObject } from '../object/is_object.js'
import type { Properties } from '../object/properties.js'
import type { And, Or } from '../predicates/logical.js'
import type { IsSymbol } from '../symbol/symbol_type.js'
Expand Down
4 changes: 3 additions & 1 deletion type-plus/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ export * as NumericPlus from './numeric/numeric_plus.js'
export type * from './numeric/numeric_type.js'
export type { Required, RequiredExcept, RequiredPick } from './object/Required.js'
export * from './object/index.js'
export type * from './object/is_not_object.js'
export type * from './object/is_object.js'
export type * from './object/is_strict_object.js'
export * as ObjectPlus from './object/object_plus.js'
export type { IsNotObject, IsObject, NotObjectType, ObjectType } from './object/object_type.js'
export type { NotObjectType, ObjectType } from './object/object_type.js'
export * from './predicates/index.js'
export type { PrimitiveTypes } from './primitive.js'
export * from './promise/index.js'
Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions type-plus/ts/object/is_not_object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { ObjectType } from './object_type.js'

/**
* Is `T` not an `object`.
*
* Note that `Function` is also an `object`.
*
* ```ts
* type R = IsNotObject<{}> // false
* type R = IsNotObject<{ a: 1 }> // false
* type R = IsNotObject<Function> // false
*
* type R = IsNotObject<number> // true
* ```
*/

export type IsNotObject<T, Then = true, Else = false> = ObjectType<T, Else, Then>
File renamed without changes.
17 changes: 17 additions & 0 deletions type-plus/ts/object/is_object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { ObjectType } from './object_type.js'

/**
* Is `T` an `object`.
*
* Note that `Function`, `Array`, and *tuple* are also `object`.
*
* ```ts
* type R = IsObject<{}> // true
* type R = IsObject<{ a: 1 }> // true
* type R = IsObject<Function> // true
*
* type R = IsObject<number> // false
* ```
*/

export type IsObject<T, Then = true, Else = false> = ObjectType<T, Then, Else>
2 changes: 1 addition & 1 deletion type-plus/ts/object/is_strict_object.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IdentityEqual } from '../equal/identity_equal.js'
import type { IsNever } from '../never/is_never.js'
import type { IsObject } from './object_type.js'
import type { IsObject } from './is_object.js'

/**
* 🎭 *predicate*
Expand Down
30 changes: 0 additions & 30 deletions type-plus/ts/object/object_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@ export type ObjectType<T, Then = T, Else = never> = IsAnyOrNever<T, $SelectionBr
: R extends $Else ? [T] extends [object] ? Then : Else
: never : never

/**
* Is `T` an `object`.
*
* Note that `Function`, `Array`, and *tuple* are also `object`.
*
* ```ts
* type R = IsObject<{}> // true
* type R = IsObject<{ a: 1 }> // true
* type R = IsObject<Function> // true
*
* type R = IsObject<number> // false
* ```
*/
export type IsObject<T, Then = true, Else = false> = ObjectType<T, Then, Else>

/**
* Check if `T` is not an `object`.
*
Expand All @@ -44,18 +29,3 @@ export type IsObject<T, Then = true, Else = false> = ObjectType<T, Then, Else>
* ```
*/
export type NotObjectType<T, Then = T, Else = never> = ObjectType<T, Else, Then>

/**
* Is `T` not an `object`.
*
* Note that `Function` is also an `object`.
*
* ```ts
* type R = IsNotObject<{}> // false
* type R = IsNotObject<{ a: 1 }> // false
* type R = IsNotObject<Function> // false
*
* type R = IsNotObject<number> // true
* ```
*/
export type IsNotObject<T, Then = true, Else = false> = ObjectType<T, Else, Then>
2 changes: 1 addition & 1 deletion type-plus/ts/testing/test_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { IsNever } from '../never/is_never.js'
import type { IsNull } from '../null/is_null.js'
import type { IsNumber } from '../number/is_number.js'
import type { IsStrictNumber } from '../number/is_strict_number.js'
import type { IsObject } from '../object/object_type.js'
import type { IsObject } from '../object/is_object.js'
import type { CanAssign, StrictCanAssign } from '../predicates/CanAssign.js'
import type { IsStrictString } from '../string/strict_string_type.js'
import type { IsString } from '../string/string_type.js'
Expand Down

0 comments on commit bfeefe0

Please sign in to comment.