From 230d06a8dfdc996ced0ae9f86d5ab8cac94ee21c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 22 Jun 2020 00:48:57 +0800 Subject: [PATCH] BREAKING CHANGE: drop createComponent --- src/component/component.ts | 40 ------------------------------ src/component/index.ts | 1 - src/index.ts | 1 - test/types/defineComponent.spec.ts | 35 -------------------------- 4 files changed, 77 deletions(-) diff --git a/src/component/component.ts b/src/component/component.ts index 8751a22b..c08d657e 100644 --- a/src/component/component.ts +++ b/src/component/component.ts @@ -119,43 +119,3 @@ export function defineComponent< export function defineComponent(options: any) { return options as any } - -// overload 1: object format with no props -export function createComponent( - options: ComponentOptionsWithoutProps -): VueProxy -// overload 2: object format with array props declaration -// props inferred as { [key in PropNames]?: any } -// return type is for Vetur and TSX support -export function createComponent< - PropNames extends string, - RawBindings = Data, - PropsOptions extends ComponentPropsOptions = ComponentPropsOptions ->( - // prettier-ignore - options: ( - ComponentOptionsWithArrayProps) & - Omit, keyof ComponentOptionsWithProps> -): VueProxy, RawBindings> -// overload 3: object format with object props declaration -// see `ExtractPropTypes` in ./componentProps.ts -export function createComponent< - Props, - RawBindings = Data, - PropsOptions extends ComponentPropsOptions = ComponentPropsOptions ->( - // prettier-ignore - options: ( - // prefer the provided Props, otherwise infer it from PropsOptions - HasDefined extends true - ? ComponentOptionsWithProps - : ComponentOptionsWithProps) & - Omit, keyof ComponentOptionsWithProps> -): VueProxy -// implementation, deferring to defineComponent, but logging a warning in dev mode -export function createComponent(options: any) { - if (__DEV__) { - Vue.util.warn('`createComponent` has been renamed to `defineComponent`.') - } - return defineComponent(options) -} diff --git a/src/component/index.ts b/src/component/index.ts index a880a467..21217b8b 100644 --- a/src/component/index.ts +++ b/src/component/index.ts @@ -1,6 +1,5 @@ export { Data, - createComponent, defineComponent, SetupFunction, SetupContext, diff --git a/src/index.ts b/src/index.ts index c891f3d1..bea3a2f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,6 @@ export default plugin export { default as createElement } from './createElement' export { SetupContext } export { - createComponent, defineComponent, ComponentRenderProxy, PropType, diff --git a/test/types/defineComponent.spec.ts b/test/types/defineComponent.spec.ts index d4fe4b31..21f6e62f 100644 --- a/test/types/defineComponent.spec.ts +++ b/test/types/defineComponent.spec.ts @@ -1,5 +1,4 @@ import { - createComponent, defineComponent, createElement as h, ref, @@ -217,38 +216,4 @@ describe('defineComponent', () => { }) }) }) - - describe('retro-compatible with createComponent', () => { - it('should still work and warn', () => { - const warn = jest - .spyOn(global.console, 'error') - .mockImplementation(() => null) - const Child = createComponent({ - props: { msg: String }, - setup(props) { - return () => h('span', props.msg) - }, - }) - - const App = createComponent({ - setup() { - const msg = ref('hello') - return () => - h('div', [ - h(Child, { - props: { - msg: msg.value, - }, - }), - ]) - }, - }) - const vm = new Vue(App).$mount() - expect(vm.$el.querySelector('span').textContent).toBe('hello') - expect(warn.mock.calls[0][0]).toMatch( - '[Vue warn]: `createComponent` has been renamed to `defineComponent`.' - ) - warn.mockRestore() - }) - }) })