diff --git a/package.json b/package.json index ebbdd330..143c93fd 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ ], "scripts": { "local-ci": "npm run typecheck && npm run lint && npm run test && npm run format && npm run build", - "test": "vitest run && npm run test-types", - "test-types": "tsc --noEmit -p ./tests/tsconfig.tests.json", + "test": "vitest run", "lint": "eslint ./src --ext .ts", "format": "prettier --write 'src/**/*.ts?(x)' && npm run lint -- --fix", "typecheck": "tsc --noEmit", diff --git a/tests/tsconfig.tests.json b/tests/tsconfig.tests.json index 4c72b473..cb934497 100644 --- a/tests/tsconfig.tests.json +++ b/tests/tsconfig.tests.json @@ -21,7 +21,7 @@ "skipLibCheck": true }, "include": [ - "./index.test.ts", + "./*.test.ts", "./typecheck-tests.ts" ] } diff --git a/tests/typecheck-tests.ts b/tests/typecheck-tests.ts index 55a3cd3d..6818d9ff 100644 --- a/tests/typecheck-tests.ts +++ b/tests/typecheck-tests.ts @@ -4,6 +4,7 @@ * This file is ran during CI to ensure that there aren't breaking changes with types */ +import { describe, expectTypeOf, it } from 'vitest'; import { err, errAsync, @@ -33,16 +34,18 @@ type CreateTuple = : never; -(function describe(_ = 'Result') { - (function describe(_ = 'andThen') { - (function it(_ = 'Combines two equal error types (native scalar types)') { - type Expectation = Result +describe('Result', () => { + describe('andThen', () => { + it('Combines two equal error types (native scalar types)', () => { + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThen((val) => err('yoooooo dude' + val)) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Combines two equal error types (custom types)') { + it('Combines two equal error types (custom types)', () => { interface MyError { stack: string code: number @@ -50,26 +53,30 @@ type CreateTuple = type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThen((val) => err({ stack: '/blah', code: 500 })) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Creates a union of error types for disjoint types') { + it('Creates a union of error types for disjoint types', () => { interface MyError { stack: string code: number } - + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThen((val) => err(['oh nooooo'])) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers error type when returning disjoint types (native scalar types)') { - type Expectation = Result + it('Infers error type when returning disjoint types (native scalar types)', () => { + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThen((val) => { switch (val) { case 1: @@ -80,16 +87,18 @@ type CreateTuple = return err(false) } }) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers error type when returning disjoint types (custom types)') { + it('Infers error type when returning disjoint types (custom types)', () => { interface MyError { stack: string code: number } - type Expectation = Result + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThen((val) => { switch (val) { case 1: @@ -100,12 +109,14 @@ type CreateTuple = return err({ stack: '/blah', code: 500 }) } }) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers new ok type when returning both Ok and Err (same as initial)') { - type Expectation = Result + it('Infers new ok type when returning both Ok and Err (same as initial)', () => { + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThen((val) => { switch (val) { case 1: @@ -114,13 +125,15 @@ type CreateTuple = return ok(val + 456) } }) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers new ok type when returning both Ok and Err (different from initial)') { + it('Infers new ok type when returning both Ok and Err (different from initial)', () => { const initial = ok(123) - type Expectation = Result + type Expectation = Result - const result: Expectation = initial + const result = initial .andThen((val) => { switch (val) { case 1: @@ -129,16 +142,18 @@ type CreateTuple = return ok(val + ' string') } }) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers new err type when returning both Ok and Err') { + it('Infers new err type when returning both Ok and Err', () => { interface MyError { stack: string code: number } - type Expectation = Result + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThen((val) => { switch (val) { case 1: @@ -149,26 +164,32 @@ type CreateTuple = return err({ stack: '/blah', code: 500 }) } }) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'allows specifying the E and T types explicitly') { + it('allows specifying the E and T types explicitly', () => { type Expectation = Result<'yo', number> - const result: Expectation = ok(123).andThen<'yo', number>(val => { + const result = ok(123).andThen<'yo', number>(val => { return ok('yo') }) + + expectTypeOf(result).toEqualTypeOf() }); }); - (function describe(_ = 'andThrough') { - (function it(_ = 'Combines two equal error types (native scalar types)') { + describe('andThrough', () => { + it('Combines two equal error types (native scalar types)', () => { type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThrough((val) => err('yoooooo dude' + val)) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Combines two equal error types (custom types)') { + it('Combines two equal error types (custom types)', () => { interface MyError { stack: string code: number @@ -176,11 +197,13 @@ type CreateTuple = type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThrough((val) => err({ stack: '/blah', code: 500 })) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Creates a union of error types for disjoint types') { + it('Creates a union of error types for disjoint types', () => { interface MyError { stack: string code: number @@ -188,14 +211,16 @@ type CreateTuple = type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThrough((val) => err(['oh nooooo'])) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers error type when returning disjoint types (native scalar types)') { + it('Infers error type when returning disjoint types (native scalar types)', () => { type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThrough((val) => { switch (val) { case 1: @@ -206,16 +231,18 @@ type CreateTuple = return err(false) } }) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers error type when returning disjoint types (custom types)') { + it('Infers error type when returning disjoint types (custom types)', () => { interface MyError { stack: string code: number } type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThrough((val) => { switch (val) { case 1: @@ -223,15 +250,17 @@ type CreateTuple = case 2: return err(123) default: - return err({ stack: '/blah', code: 500 }) + return err({ stack: '/blah', code: 500 }) } }) + + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Returns the original ok type when returning both Ok and Err (same as initial)') { - type Expectation = Result + it('Returns the original ok type when returning both Ok and Err (same as initial)', () => { + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThrough((val) => { switch (val) { case 1: @@ -240,13 +269,14 @@ type CreateTuple = return ok(val + 456) } }) + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Returns the original ok type when returning both Ok and Err (different from initial)') { + it('Returns the original ok type when returning both Ok and Err (different from initial)', () => { const initial = ok(123) - type Expectation = Result + type Expectation = Result - const result: Expectation = initial + const result = initial .andThrough((val) => { switch (val) { case 1: @@ -255,16 +285,17 @@ type CreateTuple = return ok("Hi" + val) } }) + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'Infers new err type when returning both Ok and Err') { + it('Infers new err type when returning both Ok and Err', () => { interface MyError { stack: string code: number } - type Expectation = Result + type Expectation = Result - const result: Expectation = ok(123) + const result = ok(123) .andThrough((val) => { switch (val) { case 1: @@ -275,19 +306,21 @@ type CreateTuple = return err({ stack: '/blah', code: 500 }) } }) + expectTypeOf(result).toEqualTypeOf() }); - (function it(_ = 'allows specifying the E type explicitly') { + it('allows specifying the E type explicitly', () => { type Expectation = Result - const result: Expectation = ok(123).andThrough(val => { + const result = ok(123).andThrough(val => { return ok('yo') }) + expectTypeOf(result).toEqualTypeOf() }); }); - (function describe(_ = 'orElse') { - (function it(_ = 'the type of the argument is the error type of the result') { + describe('orElse', () => { + it('the type of the argument is the error type of the result', () => { type Expectation = string const result = ok(123) @@ -302,7 +335,7 @@ type CreateTuple = }); - (function it(_ = 'infers the err return type with multiple returns (same type) ') { + it('infers the err return type with multiple returns (same type) ', () => { type Expectation = Result const result: Expectation = ok(123) @@ -316,7 +349,7 @@ type CreateTuple = }) }); - (function it(_ = 'infers the err return type with multiple returns (different type) ') { + it('infers the err return type with multiple returns (different type) ', () => { type Expectation = Result const result: Expectation = ok(123) @@ -330,7 +363,7 @@ type CreateTuple = }) }); - (function it(_ = 'infers ok and err return types with multiple returns ') { + it('infers ok and err return types with multiple returns ', () => { type Expectation = Result const result: Expectation = ok(123) @@ -346,7 +379,7 @@ type CreateTuple = }) }); - (function it(_ = 'allows specifying the E and T types explicitly') { + it('allows specifying the E and T types explicitly', () => { type Expectation = Result<'yo', string> const result: Expectation = ok<'yo', number>('yo').orElse<'yo', string>(val => { @@ -354,14 +387,14 @@ type CreateTuple = }) }); - (function it(_ = 'Creates a union of ok types for disjoint types') { + it('Creates a union of ok types for disjoint types', () => { type Expectation = Result const result: Expectation = err([true]) .orElse((val) => ok('recovered!')) }); - (function it(_ = 'Infers ok type when returning disjoint types') { + it('Infers ok type when returning disjoint types', () => { type Expectation = Result const result: Expectation = err(123) @@ -377,7 +410,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new type when returning both Ok and Err') { + it('Infers new type when returning both Ok and Err', () => { const initial = err(123) type Expectation = Result @@ -393,8 +426,8 @@ type CreateTuple = }); }); - (function describe(_ = 'match') { - (function it(_ = 'the type of the arguments match the types of the result') { + describe('match', () => { + it('the type of the arguments match the types of the result', () => { type OKExpectation = number type ErrExpectation = string @@ -410,7 +443,7 @@ type CreateTuple = ); }); - (function it(_ = 'infers the resulting value from match callbacks (same type)') { + it('infers the resulting value from match callbacks (same type)', () => { type Expectation = boolean const okResult: Expectation = ok(123) @@ -425,7 +458,7 @@ type CreateTuple = ); }); - (function it(_ = 'infers the resulting value from match callbacks (different type)') { + it('infers the resulting value from match callbacks (different type)', () => { type Expectation = boolean | bigint const okResult: Expectation = ok('123') @@ -441,15 +474,15 @@ type CreateTuple = }); }); - (function describe(_ = 'asyncAndThen') { - (function it(_ = 'Combines two equal error types (native scalar types)') { + describe('asyncAndThen', () => { + it('Combines two equal error types (native scalar types)', () => { type Expectation = ResultAsync const result: Expectation = ok(123) .asyncAndThen((val) => errAsync('yoooooo dude' + val)) }); - (function it(_ = 'Combines two equal error types (custom types)') { + it('Combines two equal error types (custom types)', () => { interface MyError { stack: string code: number @@ -461,7 +494,7 @@ type CreateTuple = .asyncAndThen((val) => errAsync({ stack: '/blah', code: 500 })) }); - (function it(_ = 'Creates a union of error types for disjoint types') { + it('Creates a union of error types for disjoint types', () => { interface MyError { stack: string code: number @@ -474,15 +507,15 @@ type CreateTuple = }); }); - (function describe(_ = 'asyncAndThrough') { - (function it(_ = 'Combines two equal error types (native scalar types)') { + describe('asyncAndThrough', () => { + it('Combines two equal error types (native scalar types)', () => { type Expectation = ResultAsync const result: Expectation = ok(123) .asyncAndThrough((val) => errAsync('yoooooo dude' + val)) }); - (function it(_ = 'Combines two equal error types (custom types)') { + it('Combines two equal error types (custom types)', () => { interface MyError { stack: string code: number @@ -494,7 +527,7 @@ type CreateTuple = .asyncAndThrough((val) => errAsync({ stack: '/blah', code: 500 })) }); - (function it(_ = 'Creates a union of error types for disjoint types') { + it('Creates a union of error types for disjoint types', () => { interface MyError { stack: string code: number @@ -506,7 +539,7 @@ type CreateTuple = .asyncAndThrough((val) => errAsync(['oh nooooo'])) }); - (function it(_ = 'Infers error type when returning disjoint types (native scalar types)') { + it('Infers error type when returning disjoint types (native scalar types)', () => { type Expectation = ResultAsync const result: Expectation = ok(123) @@ -522,7 +555,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers error type when returning disjoint types (custom types)') { + it('Infers error type when returning disjoint types (custom types)', () => { interface MyError { stack: string code: number @@ -542,7 +575,7 @@ type CreateTuple = }) }); - (function it(_ = 'Returns the original ok type when returning both Ok and Err (same as initial)') { + it('Returns the original ok type when returning both Ok and Err (same as initial)', () => { type Expectation = Result const result: Expectation = ok(123) @@ -556,7 +589,7 @@ type CreateTuple = }) }); - (function it(_ = 'Returns the original ok type when returning both Ok and Err (different from initial)') { + it('Returns the original ok type when returning both Ok and Err (different from initial)', () => { const initial = ok(123) type Expectation = Result @@ -571,7 +604,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new err type when returning both Ok and Err') { + it('Infers new err type when returning both Ok and Err', () => { interface MyError { stack: string code: number @@ -591,7 +624,7 @@ type CreateTuple = }) }); - (function it(_ = 'allows specifying the E type explicitly') { + it('allows specifying the E type explicitly', () => { type Expectation = Result const result: Expectation = ok(123).andThrough(val => { @@ -600,7 +633,7 @@ type CreateTuple = }); - (function it(_ = 'Infers new err type when returning both Ok and Err') { + it('Infers new err type when returning both Ok and Err', () => { interface MyError { stack: string code: number @@ -623,8 +656,8 @@ type CreateTuple = }); - (function describe(_ = 'combine') { - (function it(_ = 'combines different results into one') { + describe('combine', () => { + it('combines different results into one', () => { type Expectation = Result<[ number, string, boolean, boolean ], Error | string | string[]>; const result = Result.combine([ @@ -638,7 +671,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only ok results into one') { + it('combines only ok results into one', () => { type Expectation = Result<[ number, string ], never>; const result = Result.combine([ @@ -650,7 +683,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only err results into one') { + it('combines only err results into one', () => { type Expectation = Result<[ never, never ], number | 'abc'>; const result = Result.combine([ @@ -662,7 +695,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines empty list results into one') { + it('combines empty list results into one', () => { type Expectation = Result; const results: [] = []; @@ -672,7 +705,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines arrays of results to a result of an array') { + it('combines arrays of results to a result of an array', () => { type Expectation = Result; const results: Result[] = []; @@ -682,8 +715,8 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function describe(_ = 'inference on large tuples') { - (function it(_ = 'Should correctly infer the type on tuples with 6 elements') { + describe('inference on large tuples', () => { + it('Should correctly infer the type on tuples with 6 elements', () => { type Input = CreateTuple<6, Result> type Expectation = Result, never> @@ -695,7 +728,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 7 elements') { + it('Should correctly infer the type on tuples with 7 elements', () => { type Input = CreateTuple<7, Result> type Expectation = Result, never> @@ -707,7 +740,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 8 elements') { + it('Should correctly infer the type on tuples with 8 elements', () => { type Input = CreateTuple<8, Result> type Expectation = Result, never> @@ -719,7 +752,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 9 elements') { + it('Should correctly infer the type on tuples with 9 elements', () => { type Input = CreateTuple<9, Result> type Expectation = Result, never> @@ -731,7 +764,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 10 elements') { + it('Should correctly infer the type on tuples with 10 elements', () => { type Input = CreateTuple<10, Result> type Expectation = Result, never> @@ -743,7 +776,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 11 elements') { + it('Should correctly infer the type on tuples with 11 elements', () => { type Input = CreateTuple<11, Result> type Expectation = Result, never> @@ -755,7 +788,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 12 elements') { + it('Should correctly infer the type on tuples with 12 elements', () => { type Input = CreateTuple<12, Result> type Expectation = Result, never> @@ -767,7 +800,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 13 elements') { + it('Should correctly infer the type on tuples with 13 elements', () => { type Input = CreateTuple<13, Result> type Expectation = Result, never> @@ -779,7 +812,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 14 elements') { + it('Should correctly infer the type on tuples with 14 elements', () => { type Input = CreateTuple<14, Result> type Expectation = Result, never> @@ -791,7 +824,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 15 elements') { + it('Should correctly infer the type on tuples with 15 elements', () => { type Input = CreateTuple<15, Result> type Expectation = Result, never> @@ -803,7 +836,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 16 elements') { + it('Should correctly infer the type on tuples with 16 elements', () => { type Input = CreateTuple<16, Result> type Expectation = Result, never> @@ -815,7 +848,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 17 elements') { + it('Should correctly infer the type on tuples with 17 elements', () => { type Input = CreateTuple<17, Result> type Expectation = Result, never> @@ -827,7 +860,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 18 elements') { + it('Should correctly infer the type on tuples with 18 elements', () => { type Input = CreateTuple<18, Result> type Expectation = Result, never> @@ -839,7 +872,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 19 elements') { + it('Should correctly infer the type on tuples with 19 elements', () => { type Input = CreateTuple<19, Result> type Expectation = Result, never> @@ -851,7 +884,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 20 elements') { + it('Should correctly infer the type on tuples with 20 elements', () => { type Input = CreateTuple<20, Result> type Expectation = Result, never> @@ -863,7 +896,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 21 elements') { + it('Should correctly infer the type on tuples with 21 elements', () => { type Input = CreateTuple<21, Result> type Expectation = Result, never> @@ -875,7 +908,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 22 elements') { + it('Should correctly infer the type on tuples with 22 elements', () => { type Input = CreateTuple<22, Result> type Expectation = Result, never> @@ -887,7 +920,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 23 elements') { + it('Should correctly infer the type on tuples with 23 elements', () => { type Input = CreateTuple<23, Result> type Expectation = Result, never> @@ -899,7 +932,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 24 elements') { + it('Should correctly infer the type on tuples with 24 elements', () => { type Input = CreateTuple<24, Result> type Expectation = Result, never> @@ -911,7 +944,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 25 elements') { + it('Should correctly infer the type on tuples with 25 elements', () => { type Input = CreateTuple<25, Result> type Expectation = Result, never> @@ -923,7 +956,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 26 elements') { + it('Should correctly infer the type on tuples with 26 elements', () => { type Input = CreateTuple<26, Result> type Expectation = Result, never> @@ -935,7 +968,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 27 elements') { + it('Should correctly infer the type on tuples with 27 elements', () => { type Input = CreateTuple<27, Result> type Expectation = Result, never> @@ -947,7 +980,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 28 elements') { + it('Should correctly infer the type on tuples with 28 elements', () => { type Input = CreateTuple<28, Result> type Expectation = Result, never> @@ -959,7 +992,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 29 elements') { + it('Should correctly infer the type on tuples with 29 elements', () => { type Input = CreateTuple<29, Result> type Expectation = Result, never> @@ -971,7 +1004,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 30 elements') { + it('Should correctly infer the type on tuples with 30 elements', () => { type Input = CreateTuple<30, Result> type Expectation = Result, never> @@ -983,7 +1016,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 31 elements') { + it('Should correctly infer the type on tuples with 31 elements', () => { type Input = CreateTuple<31, Result> type Expectation = Result, never> @@ -995,7 +1028,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 32 elements') { + it('Should correctly infer the type on tuples with 32 elements', () => { type Input = CreateTuple<32, Result> type Expectation = Result, never> @@ -1007,7 +1040,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 33 elements') { + it('Should correctly infer the type on tuples with 33 elements', () => { type Input = CreateTuple<33, Result> type Expectation = Result, never> @@ -1019,7 +1052,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 34 elements') { + it('Should correctly infer the type on tuples with 34 elements', () => { type Input = CreateTuple<34, Result> type Expectation = Result, never> @@ -1031,7 +1064,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 35 elements') { + it('Should correctly infer the type on tuples with 35 elements', () => { type Input = CreateTuple<35, Result> type Expectation = Result, never> @@ -1043,7 +1076,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 36 elements') { + it('Should correctly infer the type on tuples with 36 elements', () => { type Input = CreateTuple<36, Result> type Expectation = Result, never> @@ -1055,7 +1088,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 37 elements') { + it('Should correctly infer the type on tuples with 37 elements', () => { type Input = CreateTuple<37, Result> type Expectation = Result, never> @@ -1067,7 +1100,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 38 elements') { + it('Should correctly infer the type on tuples with 38 elements', () => { type Input = CreateTuple<38, Result> type Expectation = Result, never> @@ -1079,7 +1112,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 39 elements') { + it('Should correctly infer the type on tuples with 39 elements', () => { type Input = CreateTuple<39, Result> type Expectation = Result, never> @@ -1091,7 +1124,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 40 elements') { + it('Should correctly infer the type on tuples with 40 elements', () => { type Input = CreateTuple<40, Result> type Expectation = Result, never> @@ -1103,7 +1136,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 41 elements') { + it('Should correctly infer the type on tuples with 41 elements', () => { type Input = CreateTuple<41, Result> type Expectation = Result, never> @@ -1115,7 +1148,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 42 elements') { + it('Should correctly infer the type on tuples with 42 elements', () => { type Input = CreateTuple<42, Result> type Expectation = Result, never> @@ -1127,7 +1160,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 43 elements') { + it('Should correctly infer the type on tuples with 43 elements', () => { type Input = CreateTuple<43, Result> type Expectation = Result, never> @@ -1139,7 +1172,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 44 elements') { + it('Should correctly infer the type on tuples with 44 elements', () => { type Input = CreateTuple<44, Result> type Expectation = Result, never> @@ -1151,7 +1184,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 45 elements') { + it('Should correctly infer the type on tuples with 45 elements', () => { type Input = CreateTuple<45, Result> type Expectation = Result, never> @@ -1163,7 +1196,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 46 elements') { + it('Should correctly infer the type on tuples with 46 elements', () => { type Input = CreateTuple<46, Result> type Expectation = Result, never> @@ -1175,7 +1208,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 47 elements') { + it('Should correctly infer the type on tuples with 47 elements', () => { type Input = CreateTuple<47, Result> type Expectation = Result, never> @@ -1187,7 +1220,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 48 elements') { + it('Should correctly infer the type on tuples with 48 elements', () => { type Input = CreateTuple<48, Result> type Expectation = Result, never> @@ -1199,7 +1232,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 49 elements') { + it('Should correctly infer the type on tuples with 49 elements', () => { type Input = CreateTuple<49, Result> type Expectation = Result, never> @@ -1213,8 +1246,8 @@ type CreateTuple = }); }); - (function describe(_ = 'combineWithAllErrors') { - (function it(_ = 'combines different results into one') { + describe('combineWithAllErrors', () => { + it('combines different results into one', () => { type Expectation = Result<[ number, string, never, never ], (string[] | Error)[]>; const result = Result.combineWithAllErrors([ @@ -1228,7 +1261,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only ok results into one') { + it('combines only ok results into one', () => { type Expectation = Result<[ number, string ], never[]>; const result = Result.combineWithAllErrors([ @@ -1240,7 +1273,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only err results into one') { + it('combines only err results into one', () => { type Expectation = Result<[ never, never ], (number | 'string')[]>; const result = Result.combineWithAllErrors([ @@ -1252,7 +1285,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines arrays of results to a result of an array') { + it('combines arrays of results to a result of an array', () => { type Expectation = Result; const results: Result[] = []; @@ -1262,7 +1295,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines arrays of different results to a result of an array') { + it('combines arrays of different results to a result of an array', () => { type Expectation = Result<(string | boolean)[], (number | string)[]>; const results: (Result | Result)[] = []; @@ -1272,8 +1305,8 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function describe(_ = 'inference on large tuples') { - (function it(_ = 'Should correctly infer the type on tuples with 6 elements') { + describe('inference on large tuples', () => { + it('Should correctly infer the type on tuples with 6 elements', () => { type Input = CreateTuple<6, Result> type Expectation = Result, number[]> @@ -1285,7 +1318,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 15 elements') { + it('Should correctly infer the type on tuples with 15 elements', () => { type Input = CreateTuple<15, Result> type Expectation = Result, number[]> @@ -1297,7 +1330,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 30 elements') { + it('Should correctly infer the type on tuples with 30 elements', () => { type Input = CreateTuple<30, Result> type Expectation = Result, number[]> @@ -1309,7 +1342,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 49 elements') { + it('Should correctly infer the type on tuples with 49 elements', () => { type Input = CreateTuple<49 , Result> type Expectation = Result, number[]> @@ -1323,8 +1356,8 @@ type CreateTuple = }); }); - (function describe(_ = 'err') { - (function it(_ = 'infers the error type narrowly when it is a string') { + describe('err', () => { + it('infers the error type narrowly when it is a string', () => { type Expectation = Result const result = err('error') @@ -1332,7 +1365,7 @@ type CreateTuple = const assignableToCheck: Expectation = result; }); - (function it(_ = 'infers the error type widely when it is not a string') { + it('infers the error type widely when it is not a string', () => { type Expectation = Result const result = err({ abc: 123 }) @@ -1343,16 +1376,16 @@ type CreateTuple = }); -(function describe(_ = 'ResultAsync') { - (function describe(_ = 'andThen') { - (function it(_ = 'Combines two equal error types (native scalar types)') { +describe('ResultAsync', () => { + describe('andThen', () => { + it('Combines two equal error types (native scalar types)', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) .andThen((val) => err('yoooooo dude' + val)) }); - (function it(_ = 'Combines two equal error types (custom types)') { + it('Combines two equal error types (custom types)', () => { interface MyError { stack: string code: number @@ -1364,7 +1397,7 @@ type CreateTuple = .andThen((val) => err({ stack: '/blah', code: 500 })) }); - (function it(_ = 'Creates a union of error types for disjoint types') { + it('Creates a union of error types for disjoint types', () => { interface MyError { stack: string code: number @@ -1376,8 +1409,8 @@ type CreateTuple = .andThen((val) => err(['oh nooooo'])) }); - (function describe(_ = 'when returning Result types') { - (function it(_ = 'Infers error type when returning disjoint types (native scalar types)') { + describe('when returning Result types', () => { + it('Infers error type when returning disjoint types (native scalar types)', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1393,7 +1426,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers error type when returning disjoint types (custom types)') { + it('Infers error type when returning disjoint types (custom types)', () => { interface MyError { stack: string code: number @@ -1413,7 +1446,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new ok type when returning both Ok and Err (same as initial)') { + it('Infers new ok type when returning both Ok and Err (same as initial)', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1427,7 +1460,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new ok type when returning both Ok and Err (different from initial)') { + it('Infers new ok type when returning both Ok and Err (different from initial)', () => { const initial = okAsync(123) type Expectation = ResultAsync @@ -1442,7 +1475,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new err type when returning both Ok and Err') { + it('Infers new err type when returning both Ok and Err', () => { interface MyError { stack: string code: number @@ -1463,8 +1496,8 @@ type CreateTuple = }); }); - (function describe(_ = 'when returning ResultAsync types') { - (function it(_ = 'Infers error type when returning disjoint types (native scalar types)') { + describe('when returning ResultAsync types', () => { + it('Infers error type when returning disjoint types (native scalar types)', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1480,7 +1513,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers error type when returning disjoint types (custom types)') { + it('Infers error type when returning disjoint types (custom types)', () => { interface MyError { stack: string code: number @@ -1500,7 +1533,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new ok type when returning both Ok and Err (same as initial)') { + it('Infers new ok type when returning both Ok and Err (same as initial)', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1514,7 +1547,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new ok type when returning both Ok and Err (different from initial)') { + it('Infers new ok type when returning both Ok and Err (different from initial)', () => { const initial = okAsync(123) type Expectation = ResultAsync @@ -1529,7 +1562,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new err type when returning both Ok and Err') { + it('Infers new err type when returning both Ok and Err', () => { interface MyError { stack: string code: number @@ -1550,8 +1583,8 @@ type CreateTuple = }); }); - (function describe(_ = 'when returning a mix of Result and ResultAsync types') { - (function it(_ = 'allows for explicitly specifying the Ok and Err types when inference fails') { + describe('when returning a mix of Result and ResultAsync types', () => { + it('allows for explicitly specifying the Ok and Err types when inference fails', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1568,8 +1601,8 @@ type CreateTuple = }); }); - (function describe(_ = 'fromSafePromise') { - (function it(_ = 'infers err type from usage') { + describe('fromSafePromise', () => { + it('infers err type from usage', () => { type Expectation = ResultAsync const result: Expectation = fromSafePromise(new Promise((resolve) => resolve(123))) @@ -1578,8 +1611,8 @@ type CreateTuple = }); }); - (function describe(_ = 'orElse') { - (function it(_ = 'the type of the argument is the error type of the result') { + describe('orElse', () => { + it('the type of the argument is the error type of the result', () => { type Expectation = string const result = okAsync(123) @@ -1594,7 +1627,7 @@ type CreateTuple = }); - (function it(_ = 'infers the err return type with multiple returns (same type) ') { + it('infers the err return type with multiple returns (same type) ', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1608,7 +1641,7 @@ type CreateTuple = }) }); - (function it(_ = 'infers the err return type with multiple returns (different type) ') { + it('infers the err return type with multiple returns (different type) ', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1622,7 +1655,7 @@ type CreateTuple = }) }); - (function it(_ = 'infers ok and err return types with multiple returns ') { + it('infers ok and err return types with multiple returns ', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1638,7 +1671,7 @@ type CreateTuple = }) }); - (function it(_ = 'allows specifying ok and err return types when mixing Result and ResultAsync in returns ') { + it('allows specifying ok and err return types when mixing Result and ResultAsync in returns ', () => { type Expectation = ResultAsync const result: Expectation = okAsync(123) @@ -1654,14 +1687,14 @@ type CreateTuple = }) }); - (function it(_ = 'Creates a union of ok types for disjoint types') { + it('Creates a union of ok types for disjoint types', () => { type Expectation = ResultAsync const result: Expectation = errAsync([true]) .orElse((val) => ok('recovered!')) }); - (function it(_ = 'Infers ok type when returning disjoint types') { + it('Infers ok type when returning disjoint types', () => { type Expectation = ResultAsync const result: Expectation = errAsync(123) @@ -1677,7 +1710,7 @@ type CreateTuple = }) }); - (function it(_ = 'Infers new type when returning both Ok and Err') { + it('Infers new type when returning both Ok and Err', () => { const initial = errAsync(123) type Expectation = ResultAsync @@ -1693,8 +1726,8 @@ type CreateTuple = }); }); - (function describe(_ = 'combine') { - (function it(_ = 'combines different result asyncs into one') { + describe('combine', () => { + it('combines different result asyncs into one', () => { type Expectation = ResultAsync<[ number, string, boolean, boolean ], Error | string | string[]>; const result = ResultAsync.combine([ @@ -1708,7 +1741,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only ok result asyncs into one') { + it('combines only ok result asyncs into one', () => { type Expectation = ResultAsync<[ number, string ], never>; const result = ResultAsync.combine([ @@ -1720,7 +1753,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only err results into one') { + it('combines only err results into one', () => { type Expectation = ResultAsync<[ never, never ], number | string>; const result = ResultAsync.combine([ @@ -1732,7 +1765,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines empty list result asyncs into one') { + it('combines empty list result asyncs into one', () => { type Expectation = ResultAsync; const results: [] = []; @@ -1742,7 +1775,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines arrays of result asyncs to a result async of an array') { + it('combines arrays of result asyncs to a result async of an array', () => { type Expectation = ResultAsync; const results: ResultAsync[] = []; @@ -1752,8 +1785,8 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function describe(_ = 'inference on large tuples') { - (function it(_ = 'Should correctly infer the type on tuples with 6 elements') { + describe('inference on large tuples', () => { + it('Should correctly infer the type on tuples with 6 elements', () => { type Input = CreateTuple<6, ResultAsync> type Expectation = ResultAsync, never> @@ -1765,7 +1798,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 7 elements') { + it('Should correctly infer the type on tuples with 7 elements', () => { type Input = CreateTuple<7, ResultAsync> type Expectation = ResultAsync, never> @@ -1777,7 +1810,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 8 elements') { + it('Should correctly infer the type on tuples with 8 elements', () => { type Input = CreateTuple<8, ResultAsync> type Expectation = ResultAsync, never> @@ -1789,7 +1822,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 9 elements') { + it('Should correctly infer the type on tuples with 9 elements', () => { type Input = CreateTuple<9, ResultAsync> type Expectation = ResultAsync, never> @@ -1801,7 +1834,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 10 elements') { + it('Should correctly infer the type on tuples with 10 elements', () => { type Input = CreateTuple<10, ResultAsync> type Expectation = ResultAsync, never> @@ -1813,7 +1846,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 11 elements') { + it('Should correctly infer the type on tuples with 11 elements', () => { type Input = CreateTuple<11, ResultAsync> type Expectation = ResultAsync, never> @@ -1825,7 +1858,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 12 elements') { + it('Should correctly infer the type on tuples with 12 elements', () => { type Input = CreateTuple<12, ResultAsync> type Expectation = ResultAsync, never> @@ -1837,7 +1870,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 13 elements') { + it('Should correctly infer the type on tuples with 13 elements', () => { type Input = CreateTuple<13, ResultAsync> type Expectation = ResultAsync, never> @@ -1849,7 +1882,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 14 elements') { + it('Should correctly infer the type on tuples with 14 elements', () => { type Input = CreateTuple<14, ResultAsync> type Expectation = ResultAsync, never> @@ -1861,7 +1894,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 15 elements') { + it('Should correctly infer the type on tuples with 15 elements', () => { type Input = CreateTuple<15, ResultAsync> type Expectation = ResultAsync, never> @@ -1873,7 +1906,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 16 elements') { + it('Should correctly infer the type on tuples with 16 elements', () => { type Input = CreateTuple<16, ResultAsync> type Expectation = ResultAsync, never> @@ -1885,7 +1918,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 17 elements') { + it('Should correctly infer the type on tuples with 17 elements', () => { type Input = CreateTuple<17, ResultAsync> type Expectation = ResultAsync, never> @@ -1897,7 +1930,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 18 elements') { + it('Should correctly infer the type on tuples with 18 elements', () => { type Input = CreateTuple<18, ResultAsync> type Expectation = ResultAsync, never> @@ -1909,7 +1942,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 19 elements') { + it('Should correctly infer the type on tuples with 19 elements', () => { type Input = CreateTuple<19, ResultAsync> type Expectation = ResultAsync, never> @@ -1921,7 +1954,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 20 elements') { + it('Should correctly infer the type on tuples with 20 elements', () => { type Input = CreateTuple<20, ResultAsync> type Expectation = ResultAsync, never> @@ -1933,7 +1966,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 21 elements') { + it('Should correctly infer the type on tuples with 21 elements', () => { type Input = CreateTuple<21, ResultAsync> type Expectation = ResultAsync, never> @@ -1945,7 +1978,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 22 elements') { + it('Should correctly infer the type on tuples with 22 elements', () => { type Input = CreateTuple<22, ResultAsync> type Expectation = ResultAsync, never> @@ -1957,7 +1990,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 23 elements') { + it('Should correctly infer the type on tuples with 23 elements', () => { type Input = CreateTuple<23, ResultAsync> type Expectation = ResultAsync, never> @@ -1969,7 +2002,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 24 elements') { + it('Should correctly infer the type on tuples with 24 elements', () => { type Input = CreateTuple<24, ResultAsync> type Expectation = ResultAsync, never> @@ -1981,7 +2014,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 25 elements') { + it('Should correctly infer the type on tuples with 25 elements', () => { type Input = CreateTuple<25, ResultAsync> type Expectation = ResultAsync, never> @@ -1993,7 +2026,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 26 elements') { + it('Should correctly infer the type on tuples with 26 elements', () => { type Input = CreateTuple<26, ResultAsync> type Expectation = ResultAsync, never> @@ -2005,7 +2038,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 27 elements') { + it('Should correctly infer the type on tuples with 27 elements', () => { type Input = CreateTuple<27, ResultAsync> type Expectation = ResultAsync, never> @@ -2017,7 +2050,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 28 elements') { + it('Should correctly infer the type on tuples with 28 elements', () => { type Input = CreateTuple<28, ResultAsync> type Expectation = ResultAsync, never> @@ -2029,7 +2062,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 29 elements') { + it('Should correctly infer the type on tuples with 29 elements', () => { type Input = CreateTuple<29, ResultAsync> type Expectation = ResultAsync, never> @@ -2041,7 +2074,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 30 elements') { + it('Should correctly infer the type on tuples with 30 elements', () => { type Input = CreateTuple<30, ResultAsync> type Expectation = ResultAsync, never> @@ -2053,7 +2086,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 31 elements') { + it('Should correctly infer the type on tuples with 31 elements', () => { type Input = CreateTuple<31, ResultAsync> type Expectation = ResultAsync, never> @@ -2065,7 +2098,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 32 elements') { + it('Should correctly infer the type on tuples with 32 elements', () => { type Input = CreateTuple<32, ResultAsync> type Expectation = ResultAsync, never> @@ -2077,7 +2110,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 33 elements') { + it('Should correctly infer the type on tuples with 33 elements', () => { type Input = CreateTuple<33, ResultAsync> type Expectation = ResultAsync, never> @@ -2089,7 +2122,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 34 elements') { + it('Should correctly infer the type on tuples with 34 elements', () => { type Input = CreateTuple<34, ResultAsync> type Expectation = ResultAsync, never> @@ -2101,7 +2134,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 35 elements') { + it('Should correctly infer the type on tuples with 35 elements', () => { type Input = CreateTuple<35, ResultAsync> type Expectation = ResultAsync, never> @@ -2113,7 +2146,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 36 elements') { + it('Should correctly infer the type on tuples with 36 elements', () => { type Input = CreateTuple<36, ResultAsync> type Expectation = ResultAsync, never> @@ -2125,7 +2158,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 37 elements') { + it('Should correctly infer the type on tuples with 37 elements', () => { type Input = CreateTuple<37, ResultAsync> type Expectation = ResultAsync, never> @@ -2137,7 +2170,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 38 elements') { + it('Should correctly infer the type on tuples with 38 elements', () => { type Input = CreateTuple<38, ResultAsync> type Expectation = ResultAsync, never> @@ -2149,7 +2182,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 39 elements') { + it('Should correctly infer the type on tuples with 39 elements', () => { type Input = CreateTuple<39, ResultAsync> type Expectation = ResultAsync, never> @@ -2161,7 +2194,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 40 elements') { + it('Should correctly infer the type on tuples with 40 elements', () => { type Input = CreateTuple<40, ResultAsync> type Expectation = ResultAsync, never> @@ -2173,7 +2206,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 41 elements') { + it('Should correctly infer the type on tuples with 41 elements', () => { type Input = CreateTuple<41, ResultAsync> type Expectation = ResultAsync, never> @@ -2185,7 +2218,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 42 elements') { + it('Should correctly infer the type on tuples with 42 elements', () => { type Input = CreateTuple<42, ResultAsync> type Expectation = ResultAsync, never> @@ -2197,7 +2230,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 43 elements') { + it('Should correctly infer the type on tuples with 43 elements', () => { type Input = CreateTuple<43, ResultAsync> type Expectation = ResultAsync, never> @@ -2209,7 +2242,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 44 elements') { + it('Should correctly infer the type on tuples with 44 elements', () => { type Input = CreateTuple<44, ResultAsync> type Expectation = ResultAsync, never> @@ -2221,7 +2254,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 45 elements') { + it('Should correctly infer the type on tuples with 45 elements', () => { type Input = CreateTuple<45, ResultAsync> type Expectation = ResultAsync, never> @@ -2233,7 +2266,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 46 elements') { + it('Should correctly infer the type on tuples with 46 elements', () => { type Input = CreateTuple<46, ResultAsync> type Expectation = ResultAsync, never> @@ -2245,7 +2278,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 47 elements') { + it('Should correctly infer the type on tuples with 47 elements', () => { type Input = CreateTuple<47, ResultAsync> type Expectation = ResultAsync, never> @@ -2257,7 +2290,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 48 elements') { + it('Should correctly infer the type on tuples with 48 elements', () => { type Input = CreateTuple<48, ResultAsync> type Expectation = ResultAsync, never> @@ -2269,7 +2302,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 49 elements') { + it('Should correctly infer the type on tuples with 49 elements', () => { type Input = CreateTuple<49, ResultAsync> type Expectation = ResultAsync, never> @@ -2283,8 +2316,8 @@ type CreateTuple = }); }); - (function describe(_ = 'combineWithAllErrors') { - (function it(_ = 'combines different result asyncs into one') { + describe('combineWithAllErrors', () => { + it('combines different result asyncs into one', () => { type Expectation = ResultAsync<[ number, string, never, never ], (string[] | Error)[]>; const result = ResultAsync.combineWithAllErrors([ @@ -2298,7 +2331,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only ok result asyncs into one') { + it('combines only ok result asyncs into one', () => { type Expectation = ResultAsync<[ number, string ], never[]>; const result = ResultAsync.combineWithAllErrors([ @@ -2310,7 +2343,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines only err result asyncs into one') { + it('combines only err result asyncs into one', () => { type Expectation = ResultAsync<[ never, never ], (number | string)[]>; const result = ResultAsync.combineWithAllErrors([ @@ -2322,7 +2355,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines arrays of result asyncs to a result of an array') { + it('combines arrays of result asyncs to a result of an array', () => { type Expectation = ResultAsync; const results: ResultAsync[] = []; @@ -2332,7 +2365,7 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function it(_ = 'combines arrays of different result asyncs to a result of an array') { + it('combines arrays of different result asyncs to a result of an array', () => { type Expectation = ResultAsync<(string | boolean)[], (number | string)[]>; const results: (ResultAsync | ResultAsync)[] = []; @@ -2342,8 +2375,8 @@ type CreateTuple = const assignablefromCheck: typeof result = assignableToCheck; }); - (function describe(_ = 'inference on large tuples') { - (function it(_ = 'Should correctly infer the type on tuples with 6 elements') { + describe('inference on large tuples', () => { + it('Should correctly infer the type on tuples with 6 elements', () => { type Input = CreateTuple<6, ResultAsync> type Expectation = ResultAsync, number[]> @@ -2355,7 +2388,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 15 elements') { + it('Should correctly infer the type on tuples with 15 elements', () => { type Input = CreateTuple<15, ResultAsync> type Expectation = ResultAsync, number[]> @@ -2367,7 +2400,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 30 elements') { + it('Should correctly infer the type on tuples with 30 elements', () => { type Input = CreateTuple<30, ResultAsync> type Expectation = ResultAsync, number[]> @@ -2379,7 +2412,7 @@ type CreateTuple = ]) }); - (function it(_ = 'Should correctly infer the type on tuples with 49 elements') { + it('Should correctly infer the type on tuples with 49 elements', () => { type Input = CreateTuple<49 , ResultAsync> type Expectation = ResultAsync, number[]> @@ -2391,16 +2424,13 @@ type CreateTuple = ]) }); }); - - - }); }); -(function describe(_ = 'Utility types') { - (function describe(_ = 'safeTry') { - (function describe(_ = 'sync generator') { - (function it(_ = 'should correctly infer the result type when generator returns Ok') { +describe('Utility types', () => { + describe('safeTry', () => { + describe('sync generator', () => { + it('should correctly infer the result type when generator returns Ok', () => { interface ReturnMyError { name: 'ReturnMyError' } @@ -2415,7 +2445,7 @@ type CreateTuple = ]) }); - (function it(_ = 'should correctly infer the result type when generator returns Err') { + it('should correctly infer the result type when generator returns Err', () => { interface ReturnMyError { name: 'ReturnMyError'; } @@ -2430,7 +2460,7 @@ type CreateTuple = ]) }); - (function it(_ = 'infers the value type when calling "yield*"') { + it('infers the value type when calling "yield*"', () => { interface YieldMyError { name: 'YieldMyError'; } @@ -2450,7 +2480,7 @@ type CreateTuple = }) }); - (function it(_ = 'should correctly infer the result type with multiple "yield*"') { + it('should correctly infer the result type with multiple "yield*"', () => { interface FirstYieldMyError { name: 'FirstYieldMyError'; } @@ -2474,8 +2504,8 @@ type CreateTuple = }); }); - (function describe(_ = 'async generator') { - (function it(_ = 'should correctly infer the result type when generator returns OkAsync') { + describe('async generator', () => { + it('should correctly infer the result type when generator returns OkAsync', () => { interface ReturnMyError { name: 'ReturnMyError' } @@ -2490,7 +2520,7 @@ type CreateTuple = ]) }); - (function it(_ = 'should correctly infer the result type when generator returns ErrAsync') { + it('should correctly infer the result type when generator returns ErrAsync', () => { interface ReturnMyError { name: 'ReturnMyError'; } @@ -2505,7 +2535,7 @@ type CreateTuple = ]) }); - (function it(_ = 'infers the value type when calling "yield*"') { + it('infers the value type when calling "yield*"', () => { interface YieldMyError { name: 'YieldMyError'; } @@ -2525,7 +2555,7 @@ type CreateTuple = }) }); - (function it(_ = 'should correctly infer the result type with multiple "yield*"') { + it('should correctly infer the result type with multiple "yield*"', () => { interface FirstYieldMyError { name: 'FirstYieldMyError'; } @@ -2550,8 +2580,8 @@ type CreateTuple = }); }); - (function describe(_ = 'Transpose') { - (function it(_ = 'should transpose an array') { + describe('Transpose', () => { + it('should transpose an array', () => { const input: [ [ 1, 2 ], [ 3, 4 ], @@ -2570,7 +2600,7 @@ type CreateTuple = const transposed: Expectation = transpose(input) }); - (function it(_ = 'should transpose an empty array') { + it('should transpose an empty array', () => { const input: [] = [] type Expectation = [] @@ -2578,7 +2608,7 @@ type CreateTuple = const transposed: Expectation = transpose(input) }); - (function it(_ = 'should transpose incomplete array') { + it('should transpose incomplete array', () => { const input: [ [ 1, 3 ], [ 2, ] @@ -2592,7 +2622,7 @@ type CreateTuple = const transposed: Expectation = transpose(input) }); }); -})(); +}); //#region Utility function declarations for type testing diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000..d9097a49 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + typecheck: { + enabled: true, + include: ['tests/typecheck-tests.ts'], + tsconfig: 'tests/tsconfig.tests.json', + }, + }, +})