Skip to content

Commit a1792de

Browse files
authored
BREAKING CHANGE: drop createComponent (#398)
1 parent b11f14c commit a1792de

File tree

4 files changed

+0
-77
lines changed

4 files changed

+0
-77
lines changed

src/component/component.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -119,43 +119,3 @@ export function defineComponent<
119119
export function defineComponent(options: any) {
120120
return options as any
121121
}
122-
123-
// overload 1: object format with no props
124-
export function createComponent<RawBindings>(
125-
options: ComponentOptionsWithoutProps<unknown, RawBindings>
126-
): VueProxy<unknown, RawBindings>
127-
// overload 2: object format with array props declaration
128-
// props inferred as { [key in PropNames]?: any }
129-
// return type is for Vetur and TSX support
130-
export function createComponent<
131-
PropNames extends string,
132-
RawBindings = Data,
133-
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
134-
>(
135-
// prettier-ignore
136-
options: (
137-
ComponentOptionsWithArrayProps<PropNames, RawBindings>) &
138-
Omit<Vue2ComponentOptions<Vue>, keyof ComponentOptionsWithProps<never, never>>
139-
): VueProxy<Readonly<{ [key in PropNames]?: any }>, RawBindings>
140-
// overload 3: object format with object props declaration
141-
// see `ExtractPropTypes` in ./componentProps.ts
142-
export function createComponent<
143-
Props,
144-
RawBindings = Data,
145-
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
146-
>(
147-
// prettier-ignore
148-
options: (
149-
// prefer the provided Props, otherwise infer it from PropsOptions
150-
HasDefined<Props> extends true
151-
? ComponentOptionsWithProps<PropsOptions, RawBindings, Props>
152-
: ComponentOptionsWithProps<PropsOptions, RawBindings>) &
153-
Omit<Vue2ComponentOptions<Vue>, keyof ComponentOptionsWithProps<never, never>>
154-
): VueProxy<PropsOptions, RawBindings>
155-
// implementation, deferring to defineComponent, but logging a warning in dev mode
156-
export function createComponent(options: any) {
157-
if (__DEV__) {
158-
Vue.util.warn('`createComponent` has been renamed to `defineComponent`.')
159-
}
160-
return defineComponent(options)
161-
}

src/component/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export {
22
Data,
3-
createComponent,
43
defineComponent,
54
SetupFunction,
65
SetupContext,

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export default plugin
2424
export { default as createElement } from './createElement'
2525
export { SetupContext }
2626
export {
27-
createComponent,
2827
defineComponent,
2928
ComponentRenderProxy,
3029
PropType,

test/types/defineComponent.spec.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
createComponent,
32
defineComponent,
43
createElement as h,
54
ref,
@@ -217,38 +216,4 @@ describe('defineComponent', () => {
217216
})
218217
})
219218
})
220-
221-
describe('retro-compatible with createComponent', () => {
222-
it('should still work and warn', () => {
223-
const warn = jest
224-
.spyOn(global.console, 'error')
225-
.mockImplementation(() => null)
226-
const Child = createComponent({
227-
props: { msg: String },
228-
setup(props) {
229-
return () => h('span', props.msg)
230-
},
231-
})
232-
233-
const App = createComponent({
234-
setup() {
235-
const msg = ref('hello')
236-
return () =>
237-
h('div', [
238-
h(Child, {
239-
props: {
240-
msg: msg.value,
241-
},
242-
}),
243-
])
244-
},
245-
})
246-
const vm = new Vue(App).$mount()
247-
expect(vm.$el.querySelector('span').textContent).toBe('hello')
248-
expect(warn.mock.calls[0][0]).toMatch(
249-
'[Vue warn]: `createComponent` has been renamed to `defineComponent`.'
250-
)
251-
warn.mockRestore()
252-
})
253-
})
254219
})

0 commit comments

Comments
 (0)