Skip to content

Commit f2c7e97

Browse files
committed
chore: add overloads for props method
1 parent b8fe144 commit f2c7e97

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/dom-wrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class DOMWrapper<ElementType extends Element> {
2424
attributes(key: string): string
2525
attributes(key?: string): { [key: string]: string } | string {
2626
const attributes = this.element.attributes
27-
const attributeMap: { [key: string]: string } = {}
27+
const attributeMap: Record<string, string> = {}
2828
for (let i = 0; i < attributes.length; i++) {
2929
const att = attributes.item(i)!
3030
attributeMap[att.localName] = att.value

src/vue-wrapper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export class VueWrapper<T extends ComponentPublicInstance> {
4545
return this.componentVM
4646
}
4747

48-
props(selector?: string) {
48+
props(): { [key: string]: any }
49+
props(selector: string): any
50+
props(selector?: string): { [key: string]: any } | any {
4951
const props = this.componentVM.$props as { [key: string]: any }
5052
return selector ? props[selector] : props
5153
}

test-dts/wrapper.d-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,7 @@ expectType<Array<string>>(wrapper.classes())
9898
expectType<boolean>(wrapper.classes('class'))
9999
expectType<Array<string>>(domWrapper.classes())
100100
expectType<boolean>(domWrapper.classes('class'))
101+
102+
// props
103+
expectType<{ [key: string]: any }>(wrapper.props())
104+
expectType<any>(wrapper.props('prop'))

0 commit comments

Comments
 (0)