Skip to content

Conversation

cexbrayat
Copy link
Member

Adds typings to emitMixin, still in the quest for switching the TS config to strict

Adds typings to `emitMixin`, still in the quest for switching the TS config to `strict`
const originalEmit = getCurrentInstance().emit
getCurrentInstance().emit = (event: string, ...args: unknown[]) => {
;(this as any).__emitted = events
const originalEmit = getCurrentInstance()!.emit
Copy link
Member

Choose a reason for hiding this comment

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

why do we need ! here?

Copy link
Member Author

Choose a reason for hiding this comment

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

getCurrentInstance returns this instance or null (see https://github.com/vuejs/vue-next/blob/38f2d23a607cd7077da189ac274a3a0ad542cc1f/packages/runtime-core/src/component.ts#L400) So TS is not happy if we don't check if it's not null. As the mixin is only called by us, I think we're safe with just !.

Copy link
Member

Choose a reason for hiding this comment

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

Ok!

@lmiller1990 lmiller1990 merged commit 619c63e into vuejs:master May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants