Skip to content

Commit 7cdf1e5

Browse files
authored
fix(types): allow any custom options for defineComponent, fix #579 (#584)
1 parent 2d6de26 commit 7cdf1e5

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/component/componentOptions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ interface ComponentOptionsBase<
4545
Vue2ComponentOptions<Vue, D, M, C, Props>,
4646
'data' | 'computed' | 'method' | 'setup' | 'props'
4747
> {
48+
// allow any custom options
49+
[key: string]: any
50+
51+
// rewrite options api types
4852
data?: (this: Props & Vue, vm: Props) => D
4953
computed?: C
5054
methods?: M

test/types/defineComponent.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
defineComponent,
3-
h,
4-
ref,
5-
SetupContext,
6-
PropType,
7-
} from '../../src'
1+
import { defineComponent, h, ref, SetupContext, PropType } from '../../src'
82
import Router from 'vue-router'
93

104
const Vue = require('vue/dist/vue.common.js')
@@ -167,6 +161,14 @@ describe('defineComponent', () => {
167161
expect.assertions(2)
168162
})
169163

164+
it('should any custom options', () => {
165+
const App = defineComponent({
166+
foo: 'foo',
167+
bar: 'bar',
168+
})
169+
new Vue(App)
170+
})
171+
170172
it('infer the required prop', () => {
171173
const App = defineComponent({
172174
props: {

0 commit comments

Comments
 (0)