diff --git a/packages/types/src/utils.ts b/packages/types/src/utils.ts index 2e04b0a..80e66d7 100644 --- a/packages/types/src/utils.ts +++ b/packages/types/src/utils.ts @@ -19,3 +19,8 @@ export type ExtractValues = T extends object ? T : ExtractValues> : T; + +export type StrictOmit = Omit; + +// biome-ignore lint/suspicious/noExplicitAny: +export type FN = (...args: Args[]) => Return; diff --git a/packages/types/tests/fn.spec.ts b/packages/types/tests/fn.spec.ts new file mode 100644 index 0000000..f67377b --- /dev/null +++ b/packages/types/tests/fn.spec.ts @@ -0,0 +1,41 @@ +import type { FN } from '../src'; +import { describe, test, expectTypeOf } from 'vitest'; + +describe('FN', () => { + test('any function type', () => { + // biome-ignore lint/suspicious/noExplicitAny: testing + const fn = (...args: any[]) => { + return args?.[0]; + }; + + type Expected = FN; + + type Actual = typeof fn; + + expectTypeOf().toEqualTypeOf(); + }); + + test('any any[] function type', () => { + // biome-ignore lint/suspicious/noExplicitAny: testing + const fn = (...args: any[]) => { + return args; + }; + + // biome-ignore lint/suspicious/noExplicitAny: testing + type Expected = FN; + + type Actual = typeof fn; + + expectTypeOf().toEqualTypeOf(); + }); + + test('string void function type', () => { + const fn = (...args: string[]) => console.log(args); + + type Expected = FN; + + type Actual = typeof fn; + + expectTypeOf().toEqualTypeOf(); + }); +}); diff --git a/packages/types/tests/strict-omit.spec.ts b/packages/types/tests/strict-omit.spec.ts new file mode 100644 index 0000000..6cf2345 --- /dev/null +++ b/packages/types/tests/strict-omit.spec.ts @@ -0,0 +1,19 @@ +import type { StrictOmit } from '../src'; +import { describe, test, expectTypeOf } from 'vitest'; + +describe('Strict Omit', () => { + test('type omit keys of object from object', () => { + const obj = { + Bob: 'bob', + Bert: 'bert', + }; + + type Expected = { + Bob: string; + }; + + type Actual = StrictOmit; + + expectTypeOf().toEqualTypeOf(); + }); +});