Skip to content

Commit

Permalink
Remove types from Router and Vuex
Browse files Browse the repository at this point in the history
  • Loading branch information
afontcu committed Jul 30, 2021
1 parent eba2aed commit c9382eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
19 changes: 12 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import Vue, {ComponentOptions} from 'vue'
import {ThisTypedMountOptions, VueClass} from '@vue/test-utils'
import {Store, StoreOptions} from 'vuex'
import Router, {RouteConfig} from 'vue-router'
// eslint-disable-next-line import/no-extraneous-dependencies
import {
queries,
Expand Down Expand Up @@ -36,12 +34,19 @@ export interface RenderResult extends BoundFunctions<typeof queries> {
updateProps(props: object): Promise<void>
}

export interface RenderOptions<V extends Vue, S = {}>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Store = any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Routes = any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Router = any

export interface RenderOptions<V extends Vue>
// The props and store options special-cased by Vue Testing Library and NOT passed to mount().
extends Omit<ThisTypedMountOptions<V>, 'store' | 'props'> {
props?: object
store?: StoreOptions<S>
routes?: RouteConfig[] | Router
store?: Store
routes?: Routes
container?: Element
baseElement?: Element
}
Expand All @@ -50,11 +55,11 @@ export type ConfigurationCallback<V extends Vue> =
| ((
localVue: typeof Vue,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
store: Store<any>,
store: Store,
router: Router,
) => Partial<ThisTypedMountOptions<V>>)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ((localVue: typeof Vue, store: Store<any>, router: Router) => void)
| ((localVue: typeof Vue, store: Store, router: Router) => void)

export function render<V extends Vue>(
TestComponent: VueClass<V> | ComponentOptions<V>,
Expand Down
9 changes: 1 addition & 8 deletions types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ export function testOptions() {
foos: [4, 5],
bars: ['a', 'b'],
},
getters: {
fooCount() {
return this.foos.length
},
},
},
routes: [
{path: '/', name: 'home', component: SomeComponent},
Expand All @@ -129,10 +124,8 @@ export function testOptions() {

export function testConfigCallback() {
const ExamplePlugin: Vue.PluginFunction<never> = () => {}
render(SomeComponent, {}, (localVue, store, router) => {
render(SomeComponent, {}, localVue => {
localVue.use(ExamplePlugin)
store.replaceState({foo: 'bar'})
router.onError(error => console.log(error.message))
})
}

Expand Down

0 comments on commit c9382eb

Please sign in to comment.