From 5573d90a057f03ba264df89b3a22e1258a05f4f9 Mon Sep 17 00:00:00 2001 From: Carlos Rodrigues Date: Sun, 15 Aug 2021 09:20:48 +0100 Subject: [PATCH] chore: remove bad import and fix compat render type --- packages/runtime-core/src/compat/global.ts | 9 ++++++--- packages/vue-compat/__tests__/instance.spec.ts | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/runtime-core/src/compat/global.ts b/packages/runtime-core/src/compat/global.ts index 7f66e5dad59..15a4d9f7e0f 100644 --- a/packages/runtime-core/src/compat/global.ts +++ b/packages/runtime-core/src/compat/global.ts @@ -57,7 +57,7 @@ import { isCompatEnabled, softAssertCompatEnabled } from './compatConfig' -import { LegacyPublicInstance } from './instance' +import { LegacyPublicInstance, LegacyPublicProperties } from './instance' /** * @deprecated the default `Vue` export has been removed in Vue 3. The type for @@ -78,7 +78,7 @@ export type CompatVue = Pick & { nextTick: typeof nextTick use(plugin: Plugin, ...options: any[]): CompatVue - mixin(mixin: ComponentOptions): CompatVue + mixin(mixin: LegacyComponentOptions): CompatVue component(name: string): Component | undefined component(name: string, component: Component): CompatVue @@ -90,7 +90,7 @@ export type CompatVue = Pick & { /** * @deprecated */ - extend: (options?: ComponentOptions) => CompatVue + extend: (options?: LegacyComponentOptions) => CompatVue /** * @deprecated Vue 3 no longer needs set() for adding new properties. */ @@ -125,6 +125,9 @@ export type CompatVue = Pick & { super: CompatVue } +type LegacyComponentOptions = ComponentOptions & + ThisType + export let isCopyingConfig = false // exported only for test diff --git a/packages/vue-compat/__tests__/instance.spec.ts b/packages/vue-compat/__tests__/instance.spec.ts index 8b11b3d6c75..08029fb8b43 100644 --- a/packages/vue-compat/__tests__/instance.spec.ts +++ b/packages/vue-compat/__tests__/instance.spec.ts @@ -7,7 +7,6 @@ import { toggleDeprecationWarning } from '../../runtime-core/src/compat/compatConfig' import { LegacyPublicInstance } from '../../runtime-core/src/compat/instance' -import { defineComponent } from 'test-dts' beforeEach(() => { toggleDeprecationWarning(true) @@ -240,7 +239,8 @@ test('INSTANCE_LISTENERS', () => { components: { child: { template: `
`, - mounted() { + mounted(this: LegacyPublicInstance) { + // @ts-expect-error $listeners type: Record listeners = this.$listeners } } @@ -264,7 +264,7 @@ describe('INSTANCE_SCOPED_SLOTS', () => { components: { child: { compatConfig: { RENDER_FUNCTION: false }, - render() { + render(this: LegacyPublicInstance) { slots = this.$scopedSlots } } @@ -291,11 +291,14 @@ describe('INSTANCE_SCOPED_SLOTS', () => { components: { child: { compatConfig: { RENDER_FUNCTION: false }, - render() { + render(this: LegacyPublicInstance) { normalSlots = this.$slots scopedSlots = this.$scopedSlots } } + }, + render() { + this.$ } }).$mount()