Skip to content

Commit c5cab72

Browse files
ktsneddyerburgh
authored andcommitted
refactor(types): remove 2nd type parameter of find/findAll to allow type inference (#318)
1 parent 62d9841 commit c5cab72

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

types/index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ interface Wrapper<V extends Vue> extends BaseWrapper {
6767
readonly element: HTMLElement
6868
readonly options: WrapperOptions
6969

70-
find<R extends Vue, Ctor extends VueClass<R> = VueClass<R>> (selector: Ctor): Wrapper<R>
70+
find<R extends Vue> (selector: VueClass<R>): Wrapper<R>
7171
find<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
7272
find (selector: FunctionalComponentOptions): Wrapper<Vue>
7373
find (selector: string): Wrapper<Vue>
7474
find (selector: RefSelector): Wrapper<Vue>
7575

76-
findAll<R extends Vue, Ctor extends VueClass<R> = VueClass<R>> (selector: Ctor): WrapperArray<R>
76+
findAll<R extends Vue> (selector: VueClass<R>): WrapperArray<R>
7777
findAll<R extends Vue> (selector: ComponentOptions<R>): WrapperArray<R>
7878
findAll (selector: FunctionalComponentOptions): WrapperArray<Vue>
7979
findAll (selector: string): WrapperArray<Vue>

types/test/mount.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso
99
const normalWrapper = mount(normalOptions)
1010
const normalFoo: string = normalWrapper.vm.foo
1111

12-
const classWrapper = mount<ClassComponent>(ClassComponent)
12+
const classWrapper = mount(ClassComponent)
1313
const classFoo: string = classWrapper.vm.bar
1414

1515
const functinalWrapper = mount(functionalOptions)
@@ -22,7 +22,7 @@ localVue.use(Vuex)
2222

2323
const store = new Vuex.Store({})
2424

25-
mount<ClassComponent>(ClassComponent, {
25+
mount(ClassComponent, {
2626
attachToDocument: true,
2727
localVue,
2828
mocks: {
@@ -57,7 +57,7 @@ mount(functionalOptions, {
5757
/**
5858
* MountOptions should receive Vue's component options
5959
*/
60-
mount<ClassComponent>(ClassComponent, {
60+
mount(ClassComponent, {
6161
propsData: {
6262
test: 'test'
6363
},

types/test/shallow.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso
99
const normalWrapper = shallow(normalOptions)
1010
const normalFoo: string = normalWrapper.vm.foo
1111

12-
const classWrapper = shallow<ClassComponent>(ClassComponent)
12+
const classWrapper = shallow(ClassComponent)
1313
const classFoo: string = classWrapper.vm.bar
1414

1515
const functinalWrapper = shallow(functionalOptions)
@@ -22,7 +22,7 @@ localVue.use(Vuex)
2222

2323
const store = new Vuex.Store({})
2424

25-
shallow<ClassComponent>(ClassComponent, {
25+
shallow(ClassComponent, {
2626
attachToDocument: true,
2727
localVue,
2828
mocks: {
@@ -51,7 +51,7 @@ shallow(functionalOptions, {
5151
/**
5252
* ShallowOptions should receive Vue's component options
5353
*/
54-
shallow<ClassComponent>(ClassComponent, {
54+
shallow(ClassComponent, {
5555
propsData: {
5656
test: 'test'
5757
},

types/test/wrapper.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso
44
/**
55
* Tests for BaseWrapper API
66
*/
7-
let wrapper = mount<Normal>(normalOptions)
7+
let wrapper = mount(normalOptions)
88

99
let bool: boolean = wrapper.contains('.foo')
1010
bool = wrapper.contains(normalOptions)
@@ -51,12 +51,12 @@ bool = wrapper.options.attachedToDocument
5151
let found = wrapper.find('.foo')
5252
found = wrapper.find(normalOptions)
5353
found = wrapper.find(functionalOptions)
54-
found = wrapper.find<ClassComponent>(ClassComponent)
54+
found = wrapper.find(ClassComponent)
5555

5656
let array = wrapper.findAll('.bar')
5757
array = wrapper.findAll(normalOptions)
5858
array = wrapper.findAll(functionalOptions)
59-
array = wrapper.findAll<ClassComponent>(ClassComponent)
59+
array = wrapper.findAll(ClassComponent)
6060

6161
let str: string = wrapper.html()
6262
str = wrapper.text()

0 commit comments

Comments
 (0)