diff --git a/src/mount.ts b/src/mount.ts index 7183a8021..185b1aae3 100644 --- a/src/mount.ts +++ b/src/mount.ts @@ -42,7 +42,7 @@ type SlotDictionary = { interface MountingOptions { data?: () => {} extends Data - ? never + ? {} : Data extends object ? Partial : never diff --git a/src/vueShims.d.ts b/src/vueShims.d.ts index e875bbea9..d70d25bc0 100644 --- a/src/vueShims.d.ts +++ b/src/vueShims.d.ts @@ -1,5 +1,5 @@ declare module '*.vue' { // TODO: Figure out the typing for this - import Vue from 'vue' - export default any + const component: any + export default component } diff --git a/test-dts/mount.d-test.ts b/test-dts/mount.d-test.ts index 4f86d147c..2bf51be36 100644 --- a/test-dts/mount.d-test.ts +++ b/test-dts/mount.d-test.ts @@ -1,6 +1,8 @@ import { expectError, expectType } from 'tsd' import { defineComponent } from 'vue' import { mount } from '../src' +// @ts-ignore +import Hello from '../tests/components/Hello.vue' const AppWithDefine = defineComponent({ props: { @@ -20,17 +22,6 @@ expectType( }).vm.a ) -// no data provided -expectError( - mount(AppWithDefine, { - data() { - return { - myVal: 1 - } - } - }) -) - // can not receive extra props expectError( mount(AppWithDefine, { @@ -153,3 +144,12 @@ mount(AppWithProps, { } } }) + +// SFC with data option +mount(Hello, { + data() { + return { + foo: 'bar' + } + } +})