types(runtime-core): provide valid type for default $emit (#1498)

This commit is contained in:
Carlos Rodrigues
2020-07-08 16:51:03 +01:00
committed by GitHub
parent f0394e2a61
commit 1e90605c15
4 changed files with 28 additions and 11 deletions

View File

@@ -6,7 +6,8 @@ import {
reactive,
createApp,
expectError,
expectType
expectType,
ComponentPublicInstance
} from './index'
describe('with object props', () => {
@@ -669,4 +670,17 @@ describe('emits', () => {
expectError(this.$emit('nope'))
}
})
// without emits
defineComponent({
setup(props, { emit }) {
emit('test', 1)
emit('test')
}
})
// emit should be valid when ComponentPublicInstance is used.
const instance = {} as ComponentPublicInstance
instance.$emit('test', 1)
instance.$emit('test')
})