types(runtime-core): make this
void in emits validator (#1842)
This commit is contained in:
parent
223f180529
commit
5002ab53d6
@ -106,7 +106,7 @@ export interface ComponentOptionsBase<
|
|||||||
components?: Record<string, PublicAPIComponent>
|
components?: Record<string, PublicAPIComponent>
|
||||||
directives?: Record<string, Directive>
|
directives?: Record<string, Directive>
|
||||||
inheritAttrs?: boolean
|
inheritAttrs?: boolean
|
||||||
emits?: E | EE[]
|
emits?: (E | EE[]) & ThisType<void>
|
||||||
|
|
||||||
// Internal ------------------------------------------------------------------
|
// Internal ------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -710,6 +710,17 @@ describe('emits', () => {
|
|||||||
const instance = {} as ComponentPublicInstance
|
const instance = {} as ComponentPublicInstance
|
||||||
instance.$emit('test', 1)
|
instance.$emit('test', 1)
|
||||||
instance.$emit('test')
|
instance.$emit('test')
|
||||||
|
|
||||||
|
// `this` should be void inside of emits validators
|
||||||
|
defineComponent({
|
||||||
|
props: ['bar'],
|
||||||
|
emits: {
|
||||||
|
foo(): boolean {
|
||||||
|
// @ts-expect-error
|
||||||
|
return this.bar === 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('componentOptions setup should be `SetupContext`', () => {
|
describe('componentOptions setup should be `SetupContext`', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user