Skip to content

Commit

Permalink
fix(types): allow any custom options for defineComponent, fix #579 (#584
Browse files Browse the repository at this point in the history
)
  • Loading branch information
antfu committed Nov 2, 2020
1 parent 2d6de26 commit 7cdf1e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/component/componentOptions.ts
Expand Up @@ -45,6 +45,10 @@ interface ComponentOptionsBase<
Vue2ComponentOptions<Vue, D, M, C, Props>,
'data' | 'computed' | 'method' | 'setup' | 'props'
> {
// allow any custom options
[key: string]: any

// rewrite options api types
data?: (this: Props & Vue, vm: Props) => D
computed?: C
methods?: M
Expand Down
16 changes: 9 additions & 7 deletions test/types/defineComponent.spec.ts
@@ -1,10 +1,4 @@
import {
defineComponent,
h,
ref,
SetupContext,
PropType,
} from '../../src'
import { defineComponent, h, ref, SetupContext, PropType } from '../../src'
import Router from 'vue-router'

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

it('should any custom options', () => {
const App = defineComponent({
foo: 'foo',
bar: 'bar',
})
new Vue(App)
})

it('infer the required prop', () => {
const App = defineComponent({
props: {
Expand Down

2 comments on commit 7cdf1e5

@bbugh
Copy link

@bbugh bbugh commented on 7cdf1e5 Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antfu FYI the new test says it('should any custom options' - looks like it's missing a word.

@antfu
Copy link
Member Author

@antfu antfu commented on 7cdf1e5 Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in d1ff9df

Please sign in to comment.