Skip to content

Add AndAll and OrAll types #1154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix: test file and adjust type.d.ts
  • Loading branch information
benzaria committed Jun 1, 2025

Verified

This commit was signed with the committer’s verified signature.
benzaria benz
commit d1b338c97aa5988481e8432ad0de9df6693359db
9 changes: 4 additions & 5 deletions source/internal/type.d.ts
Original file line number Diff line number Diff line change
@@ -50,17 +50,17 @@ export type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknow
/**
Returns a boolean for whether the given `boolean` Union containe's `false`.
*/
export type IsNotFalse<T> = Not<IsFalse<T>>;
export type IsNotFalse<T extends boolean> = Not<IsFalse<T>>;

/**
Returns a boolean for whether the given `boolean` Union members are all `true`.
*/
export type IsTrue<T> = Extends<T, true>;
export type IsTrue<T extends boolean> = Extends<T, true>;

/**
Returns a boolean for whether the given `boolean` Union members are all `false`.
*/
export type IsFalse<T> = Extends<T, false>;
export type IsFalse<T extends boolean> = Extends<T, false>;

/**
Returns a boolean for whether the given type is primitive value or primitive type.
@@ -77,8 +77,7 @@ IsPrimitive<Object>
//=> false
```
*/
export type IsPrimitive<T> = Extends<T,Primitive>;
//TODO: Push `IsPrimitive` Branch
export type IsPrimitive<T> = Extends<T, Primitive>;

/**
Returns a boolean for whether A is false.
1 change: 1 addition & 0 deletions source/or.d.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ Or<true, false>;
//=> true

Or<false, false>;
//=> false

Or<true, boolean>;
//=> true
10 changes: 8 additions & 2 deletions test-d/and.ts
Original file line number Diff line number Diff line change
@@ -29,12 +29,18 @@ expectType<AndAll<[true, false, false,]>>(false)
expectType<AndAll<[true, true, false,]>>(false)

// @ts-expect-error
expectType<And<>>(never)
expectType<And<>>({} as any)
expectType<AndAll<[]>>(never)
expectType<And<never, never>>(never)
expectType<And<never, any>>(never)
expectType<And<any, any>>(never)

// Single value
expectType<AndAll<[true]>>(true)
expectType<AndAll<[false]>>(false)
expectType<AndAll<[boolean]>>(never)
expectType<AndAll<[never]>>(never)
expectType<AndAll<[any]>>(never)

// Test if boolean is position dependent
expectType<AndAll<[boolean, true, true, true]>>(never)
expectType<AndAll<[true, boolean, true, true]>>(never)
20 changes: 13 additions & 7 deletions test-d/or.ts
Original file line number Diff line number Diff line change
@@ -22,19 +22,25 @@ expectType<Or<never, never>>(never);

// OrAll
expectType<OrAll<[true, true, true]>>(true)
expectType<OrAll<[false, true, true,]>>(true)
expectType<OrAll<[false, false, true,]>>(true)
expectType<OrAll<[false, false, false,]>>(false)
expectType<OrAll<[true, false, false,]>>(true)
expectType<OrAll<[true, true, false,]>>(true)
expectType<OrAll<[false, true, true]>>(true)
expectType<OrAll<[false, false, true]>>(true)
expectType<OrAll<[false, false, false]>>(false)
expectType<OrAll<[true, false, false]>>(true)
expectType<OrAll<[true, true, false]>>(true)

// @ts-expect-error
expectType<Or<>>(never)
expectType<Or<>>({} as any)
expectType<OrAll<[]>>(never)
expectType<Or<never, never>>(never)
expectType<Or<never, any>>(never)
expectType<Or<any, any>>(never)

// Single value
expectType<OrAll<[true]>>(true)
expectType<OrAll<[false]>>(false)
expectType<OrAll<[boolean]>>(never)
expectType<OrAll<[never]>>(never)
expectType<OrAll<[any]>>(never)

// Test if boolean is position dependent
expectType<OrAll<[boolean, true, true, true]>>(true)
expectType<OrAll<[true, boolean, true, true]>>(true)