Skip to content

Commit

Permalink
introduced ts-calc types
Browse files Browse the repository at this point in the history
  • Loading branch information
hansoksendahl committed May 31, 2024
1 parent c479acd commit 2ba258d
Show file tree
Hide file tree
Showing 220 changed files with 1,335 additions and 1,057 deletions.
Binary file added bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion src/any/antecedent/is-array.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsArray } from '~/any/antecedent/is-array'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsArray', () => {
it('should return true if A extends any[]', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/is-falsy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsFalsy } from '~/any/antecedent/is-falsy'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsFalsy', () => {
it('should return true if A extends falsy', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/is-key.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsKey } from '~/any/antecedent/is-key'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsKey', () => {
it('should return true if A extends string | number', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/is-never.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsNever } from '~/any/antecedent/is-never'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsNever', () => {
it('should return true if A extends never', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/is-nullish.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsNullish } from '~/any/antecedent/is-nullish'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsNullish', () => {
it('should return true if A extends null | undefined', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/is-primitive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsPrimitive } from '~/any/antecedent/is-primitive'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsPrimitive', () => {
it('should return true if A extends primitive', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/is-truthy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsTruthy } from '~/any/antecedent/is-truthy'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsTruthy', () => {
it('should return true if A extends true', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/primitives/is-bigint.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsBigInt } from '~/any/antecedent/primitives/is-bigint'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsBigInt', () => {
it('should return true if A extends bigint', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/primitives/is-boolean.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsBoolean } from '~/any/antecedent/primitives/is-boolean'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsBoolean', () => {
it('should return true if A extends boolean', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/primitives/is-null.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsNull } from '~/any/antecedent/primitives/is-null'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsNull', () => {
it('should return true if A extends null', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/primitives/is-number.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsNumber } from '~/any/antecedent/primitives/is-number'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsNumber', () => {
it('should return true if A extends number', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/primitives/is-string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsString } from '~/any/antecedent/primitives/is-string'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsString', () => {
it('should return true if A extends string', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/primitives/is-symbol.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsSymbol } from '~/any/antecedent/primitives/is-symbol'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsSymbol', () => {
it('should return true if A extends symbol', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/antecedent/primitives/is-undefined.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsUndefined } from '~/any/antecedent/primitives/is-undefined'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsUndefined', () => {
it('should return true if A extends undefined', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-alphabetic.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyAlphabetic } from '~/any/any-alphabetic'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyAlphabetic', () => {
it('should be an alphabetic character', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-array.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyArray } from '~/any/any-array'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyArray', () => {
it('should equal any[]', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-decimal-digit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyDecimalDigit } from '~/any/any-decimal-digit'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyDecimalDigit', () => {
it('should be a decimal digit', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-falsy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyFalsy } from '~/any/any-falsy'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyFalsy', () => {
it("should equal '' | 0 | 0n | false | null | undefined", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-function.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyFunction } from '~/any/any-function'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyFunction', () => {
it('should equal (...args: any[]) => any', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-key.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyKey } from '~/any/any-key'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyKey', () => {
it('should equal string | number | symbol', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-map.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyMap } from '~/any/any-map'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyMap', () => {
it('should equal Map<any, any>', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-nullish.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyNullish } from '~/any/any-nullish'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyNullish', () => {
it('should equal null | undefined', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-object.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AnyKey } from '~/any/any-key'
import type { AnyObject } from '~/any/any-object'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyObject', () => {
it('should equal Record<any, any>', () => {
Expand Down
7 changes: 4 additions & 3 deletions src/any/any-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* type Ex2 = AnyObject<'a' | 'b', boolean> // { a: boolean, b: boolean }
* ```
*/
export type AnyObject<A extends PropertyKey = PropertyKey, B = any> = {
[C in A]: B
}
export type AnyObject<A extends PropertyKey = PropertyKey, B = any> = Record<
A,
B
>
2 changes: 1 addition & 1 deletion src/any/any-primitive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyPrimitive } from '~/any/any-primitive'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyPrimitive', () => {
it('should be a union of all primitive types', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-set.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnySet } from '~/any/any-set'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnySet', () => {
it('should be a Set of any type', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-stringish.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyStringish } from '~/any/any-stringish'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyStringish', () => {
it('should be a union of all TypeScript type that can be coercedto a string easily.', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/any-weak-map.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyWeakMap } from '~/any/any-weak-map'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyWeakMap', () => {
it('should be a WeakMap of any type', () => {
Expand Down
5 changes: 2 additions & 3 deletions src/any/any-weak-set.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import type { AnyObject } from '~/any/any-object'
import type { AnyWeakSet } from '~/any/any-weak-set'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('AnyWeakSet', () => {
it('should be a WeakSet of any type', () => {
type Ex = AnyWeakSet

type TestEx = Expect<IsEqual<Ex, WeakSet<AnyObject>>>
type TestEx = Expect<IsEqual<Ex, WeakSet<object>>>
})

it('should be a WeakSet of type A', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/any/to-string.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ToString } from '~/any/to-string'
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('ToString', () => {
it('should convert `A` to a string', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/any/to-string.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { AnyStringish } from '~/any/any-stringish'
import type { HelperToStringInterface } from '~/helper/to-string-interface'
import type { ToStringInterface } from '~/helper/to-string-interface'

export type ToString<A> = A extends AnyStringish
? `${A}`
: A extends HelperToStringInterface
: A extends ToStringInterface
? ReturnType<A['toString']>
: never
2 changes: 1 addition & 1 deletion src/extension/antecedent/is-equal.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'
import type { IsEqual } from './is-equal'

describe('IsEqual', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/extension/antecedent/is-equal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IsExtension } from '~/extension/antecedent/is-extension'
import type { IsExtension } from './is-extension'

/**
* If `A extends B` and `B extends A` then `true` else `false`
Expand Down
2 changes: 1 addition & 1 deletion src/extension/antecedent/is-extension.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IsExtension } from '~/extension/antecedent/is-extension'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'
import type { IsEqual } from './is-equal'

describe('IsExtension', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/antecedent/is-constructor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { IsConstructor } from '~/function/antecedent/is-constructor'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsConstructor', () => {
it('hould return true if the function is a constructor', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/antecedent/is-function.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { IsFunction } from '~/function/antecedent/is-function'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('IsFunction', () => {
it('should return true if the function is a function', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-0.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity0 } from '~/function/arity/arity-0'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity0', () => {
it('should be a function with 0 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity1 } from '~/function/arity/arity-1'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'
import type { Arity0 } from './arity-0'

describe('Arity1', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity2 } from '~/function/arity/arity-2'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity2', () => {
it('should be a function with 2 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-3.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity3 } from '~/function/arity/arity-3'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity3', () => {
it('should be a function with 3 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-4.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity4 } from '~/function/arity/arity-4'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity4', () => {
it('should be a function with 4 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-5.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity5 } from '~/function/arity/arity-5'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity5', () => {
it('should be a function with 5 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-6.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity6 } from '~/function/arity/arity-6'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity6', () => {
it('should be a function with 6 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-7.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity7 } from '~/function/arity/arity-7'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity7', () => {
it('should be a function with 7 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/arity/arity-8.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Arity8 } from '~/function/arity/arity-8'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Arity8', () => {
it('should be a function with 8 parameters', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/constructor-return-type.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { ConstructorReturnType } from '~/function/constructor-return-type'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('ConstructorReturnType', () => {
it('should return the type of the constructor', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/constructor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Constructor } from '~/function/constructor'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Constructor', () => {
it('should be a function with 1 argument', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/function/factory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IsEqual } from '~/extension/antecedent/is-equal'
import type { Factory } from '~/function/factory'
import type { Expect } from '~/helper/test'
import type { Expect } from '~/helper/expect'

describe('Factory', () => {
it('should work without specifying any typeParams', () => {
Expand Down
Loading

0 comments on commit 2ba258d

Please sign in to comment.