refactor(createComponent): rename to defineComponent (#549)

This commit is contained in:
Chris Fritz
2019-12-22 10:58:12 -05:00
committed by Evan You
parent 7d2ae08277
commit 1c4cdd841d
18 changed files with 74 additions and 74 deletions

View File

@@ -1,5 +1,5 @@
import { expectError, expectType } from 'tsd'
import { describe, createComponent, PropType, ref } from './index'
import { describe, defineComponent, PropType, ref } from './index'
describe('with object props', () => {
interface ExpectedProps {
@@ -12,7 +12,7 @@ describe('with object props', () => {
ddd: string[]
}
const MyComponent = createComponent({
const MyComponent = defineComponent({
props: {
a: Number,
// required should make property non-void
@@ -126,7 +126,7 @@ describe('with object props', () => {
})
describe('type inference w/ optional props declaration', () => {
const MyComponent = createComponent({
const MyComponent = defineComponent({
setup(_props: { msg: string }) {
return {
a: 1
@@ -149,14 +149,14 @@ describe('type inference w/ optional props declaration', () => {
})
describe('type inference w/ direct setup function', () => {
const MyComponent = createComponent((_props: { msg: string }) => {})
const MyComponent = defineComponent((_props: { msg: string }) => {})
expectType<JSX.Element>(<MyComponent msg="foo" />)
expectError(<MyComponent />)
expectError(<MyComponent msg={1} />)
})
describe('type inference w/ array props declaration', () => {
createComponent({
defineComponent({
props: ['a', 'b'],
setup(props) {
// props should be readonly
@@ -179,7 +179,7 @@ describe('type inference w/ array props declaration', () => {
})
describe('type inference w/ options API', () => {
createComponent({
defineComponent({
props: { a: Number },
setup() {
return {

View File

@@ -2,7 +2,7 @@ import { expectError } from 'tsd'
import {
describe,
h,
createComponent,
defineComponent,
ref,
Fragment,
Portal,
@@ -71,8 +71,8 @@ describe('h inference w/ plain object component', () => {
expectError(h(Foo, { foo: 1 }))
})
describe('h inference w/ createComponent', () => {
const Foo = createComponent({
describe('h inference w/ defineComponent', () => {
const Foo = defineComponent({
props: {
foo: String,
bar: {
@@ -93,8 +93,8 @@ describe('h inference w/ createComponent', () => {
expectError(h(Foo, { bar: 1, foo: 1 }))
})
describe('h inference w/ createComponent + optional props', () => {
const Foo = createComponent({
describe('h inference w/ defineComponent + optional props', () => {
const Foo = defineComponent({
setup(_props: { foo?: string; bar: number }) {}
})
@@ -109,8 +109,8 @@ describe('h inference w/ createComponent + optional props', () => {
expectError(h(Foo, { bar: 1, foo: 1 }))
})
describe('h inference w/ createComponent + direct function', () => {
const Foo = createComponent((_props: { foo?: string; bar: number }) => {})
describe('h inference w/ defineComponent + direct function', () => {
const Foo = defineComponent((_props: { foo?: string; bar: number }) => {})
h(Foo, { bar: 1 })
h(Foo, { bar: 1, foo: 'ok' })

View File

@@ -1,4 +1,4 @@
// TSX w/ createComponent is tested in createComponent.test-d.tsx
// TSX w/ defineComponent is tested in defineComponent.test-d.tsx
import { expectError, expectType } from 'tsd'
import { KeepAlive, Suspense, Fragment, Portal } from '@vue/runtime-dom'