Skip to content

Commit

Permalink
chore(types): improve typing of emitted (#1640)
Browse files Browse the repository at this point in the history
  • Loading branch information
xanf committed Jul 2, 2022
1 parent 077432c commit ae5bc03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vueWrapper.ts
Expand Up @@ -172,7 +172,7 @@ export class VueWrapper<
}

emitted<T = unknown>(): Record<string, T[]>
emitted<T = unknown>(eventName: string): undefined | T[]
emitted<T = unknown[]>(eventName: string): undefined | T[]
emitted<T = unknown>(
eventName?: string
): undefined | T[] | Record<string, T[]> {
Expand Down
5 changes: 5 additions & 0 deletions test-dts/wrapper.d-test.ts
Expand Up @@ -62,6 +62,11 @@ byClassArray = domWrapper.findAll('.todo')
expectType<Element | undefined>(byClassArray[0].element)

// emitted

// event name without specific type
let incrementEventWithoutType = wrapper.emitted('increment')
expectType<unknown[][] | undefined>(incrementEventWithoutType)

// event name
let incrementEvent = wrapper.emitted<{ count: number }>('increment')
expectType<{ count: number }[] | undefined>(incrementEvent)
Expand Down

0 comments on commit ae5bc03

Please sign in to comment.