File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @file Unit Tests - NodeError
3+ * @module create-node-error/types/tests/unit-d/NodeError
4+ */
5+
6+ import type { ErrorCode } from '#src/enums'
7+ import type TestSubject from '../node-error'
8+
9+ describe ( 'unit-d:types/NodeError' , ( ) => {
10+ it ( 'should have type param extend Error type' , ( ) => {
11+ expectTypeOf < TestSubject > ( ) . toMatchTypeOf < Error > ( )
12+ expectTypeOf < TestSubject < RangeError > > ( ) . toMatchTypeOf < RangeError > ( )
13+ expectTypeOf < TestSubject < TypeError > > ( ) . toMatchTypeOf < TypeError > ( )
14+ } )
15+
16+ it ( 'should match [code: ErrorCode]' , ( ) => {
17+ expectTypeOf < TestSubject > ( )
18+ . toHaveProperty ( 'code' )
19+ . toEqualTypeOf < ErrorCode > ( )
20+ } )
21+ } )
Original file line number Diff line number Diff line change 44 */
55
66export type { default as MessageFn } from './fn-message'
7+ export type { default as NodeError } from './node-error'
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Type Definitions - NodeError
3+ * @module create-node-error/types/NodeError
4+ */
5+
6+ import type { ErrorCode } from '#src/enums'
7+
8+ /**
9+ * Node.js error.
10+ *
11+ * @template T - Error base type
12+ *
13+ * @extends {T }
14+ */
15+ type NodeError < T extends Error = Error > = T & {
16+ /**
17+ * Error code.
18+ */
19+ code : ErrorCode
20+ }
21+
22+ export type { NodeError as default }
You can’t perform that action at this time.
0 commit comments