Skip to content

Commit bb8f2fd

Browse files
committed
fix(types): keep compatible with VueComponentOptions
Keep return type of `createComponent` compatible with `VueComponentOptions`. Resolves: #130
1 parent a979c00 commit bb8f2fd

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"rollup-plugin-typescript2": "^0.21.0",
4646
"ts-jest": "^24.0.2",
4747
"typescript": "^3.6.2",
48-
"vue": "^2.5.22"
48+
"vue": "^2.5.22",
49+
"vue-router": "^3.1.3"
4950
},
5051
"peerDependencies": {
5152
"vue": "^2.5.22"

src/component/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type VueConstructorProxy<PropsOptions, RawBindings> = {
3131
};
3232

3333
type VueProxy<PropsOptions, RawBindings> = Vue2ComponentOptions<
34-
never,
34+
Vue,
3535
UnwrapRef<RawBindings>,
3636
never,
3737
never,

test/types/createComponent.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { createComponent, createElement as h, ref, SetupContext } from '../../src';
2+
import Router from 'vue-router';
3+
24
const Vue = require('vue/dist/vue.common.js');
35

46
type Equal<Left, Right> = (<U>() => U extends Left ? 1 : 0) extends (<U>() => U extends Right
@@ -128,4 +130,18 @@ describe('createComponent', () => {
128130
new Vue(App);
129131
expect.assertions(2);
130132
});
133+
134+
describe('compatible with vue router', () => {
135+
it('RouteConfig.component', () => {
136+
new Router({
137+
routes: [
138+
{
139+
path: '/',
140+
name: 'root',
141+
component: createComponent({}),
142+
},
143+
],
144+
});
145+
});
146+
});
131147
});

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,6 +4240,11 @@ [email protected]:
42404240
core-util-is "1.0.2"
42414241
extsprintf "^1.2.0"
42424242

4243+
vue-router@^3.1.3:
4244+
version "3.1.3"
4245+
resolved "https://registry.npm.taobao.org/vue-router/download/vue-router-3.1.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-router%2Fdownload%2Fvue-router-3.1.3.tgz#e6b14fabc0c0ee9fda0e2cbbda74b350e28e412b"
4246+
integrity sha1-5rFPq8DA7p/aDiy72nSzUOKOQSs=
4247+
42434248
vue@^2.5.22:
42444249
version "2.6.10"
42454250
resolved "https://registry.npm.taobao.org/vue/download/vue-2.6.10.tgz#a72b1a42a4d82a721ea438d1b6bf55e66195c637"

0 commit comments

Comments
 (0)