Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(types): remove 2nd type parameter of find/findAll to allow type inference #318

Merged
merged 1 commit into from
Jan 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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