Skip to content

Commit 96b4d76

Browse files
committed
fix(runtime-core): Custom type props warning
1 parent f3e4f03 commit 96b4d76

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: packages/runtime-core/src/componentProps.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,13 @@ function validatePropName(key: string) {
557557
// use function string name to check type constructors
558558
// so that it works across vms / iframes.
559559
function getType(ctor: Prop<any>): string {
560-
const match = ctor && ctor.toString().match(/^\s*function (\w+)/)
560+
const ctorStr = ctor && ctor.toString()
561+
let match: RegExpMatchArray | null
562+
if (ctorStr.startsWith('class')) {
563+
match = ctor && ctor.toString().match(/^\s*class (\w+)/)
564+
} else {
565+
match = ctor && ctor.toString().match(/^\s*function (\w+)/)
566+
}
561567
return match ? match[1] : ctor === null ? 'null' : ''
562568
}
563569

0 commit comments

Comments
 (0)