Skip to content

Commit 5573d90

Browse files
committed
chore: remove bad import and fix compat render type
1 parent 675a642 commit 5573d90

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/runtime-core/src/compat/global.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import {
5757
isCompatEnabled,
5858
softAssertCompatEnabled
5959
} from './compatConfig'
60-
import { LegacyPublicInstance } from './instance'
60+
import { LegacyPublicInstance, LegacyPublicProperties } from './instance'
6161

6262
/**
6363
* @deprecated the default `Vue` export has been removed in Vue 3. The type for
@@ -78,7 +78,7 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
7878
nextTick: typeof nextTick
7979

8080
use(plugin: Plugin, ...options: any[]): CompatVue
81-
mixin(mixin: ComponentOptions): CompatVue
81+
mixin(mixin: LegacyComponentOptions): CompatVue
8282

8383
component(name: string): Component | undefined
8484
component(name: string, component: Component): CompatVue
@@ -90,7 +90,7 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
9090
/**
9191
* @deprecated
9292
*/
93-
extend: (options?: ComponentOptions) => CompatVue
93+
extend: (options?: LegacyComponentOptions) => CompatVue
9494
/**
9595
* @deprecated Vue 3 no longer needs set() for adding new properties.
9696
*/
@@ -125,6 +125,9 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
125125
super: CompatVue
126126
}
127127

128+
type LegacyComponentOptions = ComponentOptions &
129+
ThisType<LegacyPublicProperties>
130+
128131
export let isCopyingConfig = false
129132

130133
// exported only for test

packages/vue-compat/__tests__/instance.spec.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
toggleDeprecationWarning
88
} from '../../runtime-core/src/compat/compatConfig'
99
import { LegacyPublicInstance } from '../../runtime-core/src/compat/instance'
10-
import { defineComponent } from 'test-dts'
1110

1211
beforeEach(() => {
1312
toggleDeprecationWarning(true)
@@ -240,7 +239,8 @@ test('INSTANCE_LISTENERS', () => {
240239
components: {
241240
child: {
242241
template: `<div/>`,
243-
mounted() {
242+
mounted(this: LegacyPublicInstance) {
243+
// @ts-expect-error $listeners type: Record<string, Function | Function[]>
244244
listeners = this.$listeners
245245
}
246246
}
@@ -264,7 +264,7 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
264264
components: {
265265
child: {
266266
compatConfig: { RENDER_FUNCTION: false },
267-
render() {
267+
render(this: LegacyPublicInstance) {
268268
slots = this.$scopedSlots
269269
}
270270
}
@@ -291,11 +291,14 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
291291
components: {
292292
child: {
293293
compatConfig: { RENDER_FUNCTION: false },
294-
render() {
294+
render(this: LegacyPublicInstance) {
295295
normalSlots = this.$slots
296296
scopedSlots = this.$scopedSlots
297297
}
298298
}
299+
},
300+
render() {
301+
this.$
299302
}
300303
}).$mount()
301304

0 commit comments

Comments
 (0)