Skip to content

Commit

Permalink
refactor(types): remove 2nd type parameter of find/findAll to allow t…
Browse files Browse the repository at this point in the history
…ype inference (#318)
  • Loading branch information
ktsn authored and eddyerburgh committed Jan 1, 2018
1 parent 62d9841 commit c5cab72
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ interface Wrapper<V extends Vue> extends BaseWrapper {
readonly element: HTMLElement
readonly options: WrapperOptions

find<R extends Vue, Ctor extends VueClass<R> = VueClass<R>> (selector: Ctor): Wrapper<R>
find<R extends Vue> (selector: VueClass<R>): Wrapper<R>
find<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
find (selector: FunctionalComponentOptions): Wrapper<Vue>
find (selector: string): Wrapper<Vue>
find (selector: RefSelector): Wrapper<Vue>

findAll<R extends Vue, Ctor extends VueClass<R> = VueClass<R>> (selector: Ctor): WrapperArray<R>
findAll<R extends Vue> (selector: VueClass<R>): WrapperArray<R>
findAll<R extends Vue> (selector: ComponentOptions<R>): WrapperArray<R>
findAll (selector: FunctionalComponentOptions): WrapperArray<Vue>
findAll (selector: string): WrapperArray<Vue>
Expand Down
6 changes: 3 additions & 3 deletions types/test/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso
const normalWrapper = mount(normalOptions)
const normalFoo: string = normalWrapper.vm.foo

const classWrapper = mount<ClassComponent>(ClassComponent)
const classWrapper = mount(ClassComponent)
const classFoo: string = classWrapper.vm.bar

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

const store = new Vuex.Store({})

mount<ClassComponent>(ClassComponent, {
mount(ClassComponent, {
attachToDocument: true,
localVue,
mocks: {
Expand Down Expand Up @@ -57,7 +57,7 @@ mount(functionalOptions, {
/**
* MountOptions should receive Vue's component options
*/
mount<ClassComponent>(ClassComponent, {
mount(ClassComponent, {
propsData: {
test: 'test'
},
Expand Down
6 changes: 3 additions & 3 deletions types/test/shallow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso
const normalWrapper = shallow(normalOptions)
const normalFoo: string = normalWrapper.vm.foo

const classWrapper = shallow<ClassComponent>(ClassComponent)
const classWrapper = shallow(ClassComponent)
const classFoo: string = classWrapper.vm.bar

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

const store = new Vuex.Store({})

shallow<ClassComponent>(ClassComponent, {
shallow(ClassComponent, {
attachToDocument: true,
localVue,
mocks: {
Expand Down Expand Up @@ -51,7 +51,7 @@ shallow(functionalOptions, {
/**
* ShallowOptions should receive Vue's component options
*/
shallow<ClassComponent>(ClassComponent, {
shallow(ClassComponent, {
propsData: {
test: 'test'
},
Expand Down
6 changes: 3 additions & 3 deletions types/test/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso
/**
* Tests for BaseWrapper API
*/
let wrapper = mount<Normal>(normalOptions)
let wrapper = mount(normalOptions)

let bool: boolean = wrapper.contains('.foo')
bool = wrapper.contains(normalOptions)
Expand Down Expand Up @@ -51,12 +51,12 @@ bool = wrapper.options.attachedToDocument
let found = wrapper.find('.foo')
found = wrapper.find(normalOptions)
found = wrapper.find(functionalOptions)
found = wrapper.find<ClassComponent>(ClassComponent)
found = wrapper.find(ClassComponent)

let array = wrapper.findAll('.bar')
array = wrapper.findAll(normalOptions)
array = wrapper.findAll(functionalOptions)
array = wrapper.findAll<ClassComponent>(ClassComponent)
array = wrapper.findAll(ClassComponent)

let str: string = wrapper.html()
str = wrapper.text()
Expand Down

0 comments on commit c5cab72

Please sign in to comment.