Skip to content

Commit dab6415

Browse files
committed
fix: type definition
1 parent f41e9e6 commit dab6415

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

__tests__/index.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import fs from 'fs'
22
import { depend } from '../src'
33

4+
test('injest option args', () => {
5+
const handler = depend({ print: (text?: string) => alert(text) }, ({ print }, a?: string) => {
6+
return print(a)
7+
})
8+
9+
expect(handler.inject({ print: text => text })('test')).toBe('test')
10+
expect(handler.inject({ print: text => text })()).toBeUndefined()
11+
})
12+
413
test('inject add', () => {
514
const add = (a: number, b: number) => a + b
615
const basicFn = depend({ add }, ({ add }, a: number, b: number, c: number) => add(a, b) * c)

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type Deps<T extends Record<string, any>> = {
44
: T[P]
55
}
66

7-
export const depend = <T extends Record<string, any>, U extends [] | [any, ...any[]], V>(
7+
export const depend = <T extends Record<string, any>, U extends any[], V>(
88
dependencies: T,
99
cb: (deps: Deps<T>, ...args: U) => V
1010
) => {

0 commit comments

Comments
 (0)