Skip to content

Commit

Permalink
feat(types): DecoratorTarget
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Aug 12, 2023
1 parent e14d68a commit 01f8e6c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/types/__tests__/decorator-target.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @file Type Tests - DecoratorTarget
* @module tutils/types/tests/unit-d/DecoratorTarget
*/

import type AbstractConstructor from '../constructor-abstract'
import type TestSubject from '../decorator-target'
import type Objectify from '../objectify'

describe('unit-d:types/DecoratorTarget', () => {
it('should extract AbstractConstructor<any>', () => {
expectTypeOf<TestSubject>()
.extract<AbstractConstructor<any>>()
.not.toBeNever()
})

it('should extract Objectify<any>', () => {
expectTypeOf<TestSubject>()
.exclude<AbstractConstructor<any>>()
.toEqualTypeOf<Objectify<any>>()
})
})
16 changes: 16 additions & 0 deletions src/types/decorator-target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @file Type Definitions - MethodDecorator
* @module tutils/types/MethodDecorator
*/

import type AbstractConstructor from './constructor-abstract'
import type Objectify from './objectify'

/**
* A class declaration or prototype passed as a decorator target.
*
* @see https://mirone.me/a-complete-guide-to-typescript-decorator
*/
type DecoratorTarget = AbstractConstructor<any> | Objectify<any>

export type { DecoratorTarget as default }
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type { default as Constructor } from './constructor'
export type { default as AbstractConstructor } from './constructor-abstract'
export type { default as ContinuousValue } from './continuous-value'
export type { default as Crush } from './crush'
export type { default as DecoratorTarget } from './decorator-target'
export type { default as Defaults } from './defaults'
export type { default as Digit } from './digit'
export type { default as Dot } from './dot'
Expand Down

0 comments on commit 01f8e6c

Please sign in to comment.