Skip to content

Commit 6ab078a

Browse files
committed
fix(components): handle null prop type, closes #1559
1 parent ab3d242 commit 6ab078a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/app-backend-vue2/src/components/data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ function getPropType (type) {
155155
if (Array.isArray(type)) {
156156
return type.map(t => getPropType(t)).join(' or ')
157157
}
158+
if (type == null) {
159+
return 'null'
160+
}
158161
const match = type.toString().match(fnTypeRE)
159162
return typeof type === 'function'
160163
? (match && match[1]) || 'any'

packages/app-backend-vue3/src/components/data.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function processProps (instance) {
4444

4545
for (let key in instance.props) {
4646
const propDefinition = propDefinitions ? propDefinitions[key] : null
47+
console.log(key, propDefinition)
4748
key = camelize(key)
4849
propsData.push({
4950
type: 'props',
@@ -76,6 +77,9 @@ function getPropType (type) {
7677
if (Array.isArray(type)) {
7778
return type.map(t => getPropType(t)).join(' or ')
7879
}
80+
if (type == null) {
81+
return 'null'
82+
}
7983
const match = type.toString().match(fnTypeRE)
8084
return typeof type === 'function'
8185
? (match && match[1]) || 'any'

packages/shell-dev-vue3/src/Nested.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
99
props: {
1010
count: {
11-
type: Number,
11+
type: [Number, String, null],
1212
default: 4
1313
}
1414
},

0 commit comments

Comments
 (0)