Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/runtime-core/src/componentProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,19 @@ function assertType(
valid = t === expectedType.toLowerCase()
// for primitive wrapper objects
if (!valid && t === 'object') {
valid = value instanceof (type as PropConstructor)
// Guard against invalid prop type definitions (e.g. 'object', {}, etc.)
// Only attempt instanceof when the provided type is a function/constructor.
valid = isFunction(type) && value instanceof (type as PropConstructor)
}
} else if (expectedType === 'Object') {
valid = isObject(value)
} else if (expectedType === 'Array') {
valid = isArray(value)
} else {
valid = value instanceof (type as PropConstructor)
// Fallback to constructor check only when type is a function.
// This avoids errors like "Right-hand side of 'instanceof' is not an object"
// when users mistakenly pass invalid values (e.g. strings) in prop type.
valid = isFunction(type) && value instanceof (type as PropConstructor)
}
return {
valid,
Expand Down