Skip to content

Commit

Permalink
chore: remove bad import and fix compat render type
Browse files Browse the repository at this point in the history
  • Loading branch information
pikax committed Aug 15, 2021
1 parent 675a642 commit 5573d90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 6 additions & 3 deletions packages/runtime-core/src/compat/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -78,7 +78,7 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
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
Expand All @@ -90,7 +90,7 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
/**
* @deprecated
*/
extend: (options?: ComponentOptions) => CompatVue
extend: (options?: LegacyComponentOptions) => CompatVue
/**
* @deprecated Vue 3 no longer needs set() for adding new properties.
*/
Expand Down Expand Up @@ -125,6 +125,9 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
super: CompatVue
}

type LegacyComponentOptions = ComponentOptions &
ThisType<LegacyPublicProperties>

export let isCopyingConfig = false

// exported only for test
Expand Down
11 changes: 7 additions & 4 deletions packages/vue-compat/__tests__/instance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -240,7 +239,8 @@ test('INSTANCE_LISTENERS', () => {
components: {
child: {
template: `<div/>`,
mounted() {
mounted(this: LegacyPublicInstance) {
// @ts-expect-error $listeners type: Record<string, Function | Function[]>
listeners = this.$listeners
}
}
Expand All @@ -264,7 +264,7 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
components: {
child: {
compatConfig: { RENDER_FUNCTION: false },
render() {
render(this: LegacyPublicInstance) {
slots = this.$scopedSlots
}
}
Expand All @@ -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()

Expand Down

0 comments on commit 5573d90

Please sign in to comment.