From 6e140b4797516d9f684c8ae5aeffc43edf71e007 Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Wed, 1 Feb 2023 00:32:28 -0500 Subject: [PATCH] feat(types): `Fn` Signed-off-by: Lexus Drumgold --- src/types/__tests__/fn.spec-d.ts | 19 +++++++++++++++++++ src/types/fn.ts | 18 ++++++++++++++++++ src/types/index.ts | 1 + 3 files changed, 38 insertions(+) create mode 100644 src/types/__tests__/fn.spec-d.ts create mode 100644 src/types/fn.ts diff --git a/src/types/__tests__/fn.spec-d.ts b/src/types/__tests__/fn.spec-d.ts new file mode 100644 index 00000000..2ce8943c --- /dev/null +++ b/src/types/__tests__/fn.spec-d.ts @@ -0,0 +1,19 @@ +/** + * @file Type Tests - Fn + * @module tutils/types/tests/unit-d/Fn + */ + +import type ANY from '../any' +import type TestSubject from '../fn' + +describe('unit-d:types/Fn', () => { + it('should be callable with Args', () => { + expectTypeOf().parameters.toEqualTypeOf() + expectTypeOf>().parameters.toEqualTypeOf<[string]>() + }) + + it('should return Ret', () => { + expectTypeOf().returns.toEqualTypeOf() + expectTypeOf>().returns.toBeString() + }) +}) diff --git a/src/types/fn.ts b/src/types/fn.ts new file mode 100644 index 00000000..23b5cfd5 --- /dev/null +++ b/src/types/fn.ts @@ -0,0 +1,18 @@ +/** + * @file Type Definitions - Fn + * @module tutils/types/Fn + */ + +import type ANY from './any' + +/** + * A function. + * + * @template Args - Arguments type + * @template Ret - Return type + */ +type Fn = ( + ...args: Args +) => Ret + +export type { Fn as default } diff --git a/src/types/index.ts b/src/types/index.ts index f6b52118..0acd26b8 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -17,6 +17,7 @@ export type { default as ExactOptionalPropertyTypes } from './exact-optional-property-types' export type { default as FIXME } from './fixme' +export type { default as Fn } from './fn' export type { default as IndexSignature } from './index-signature' export type { default as IsTuple } from './is-tuple' export type { default as Join } from './join'