Skip to content

Commit f05577f

Browse files
committed
fix: handle null defaultValue in matchesShape
typeof null === 'object' caused null defaults to match any object or array. Check for null explicitly before the object/array branches.
1 parent f5d9619 commit f05577f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/omniviewdev-runtime/src/hooks/data/usePluginData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ type UsePluginDataResult<T> = {
1515
* was stored but the caller expects an array).
1616
*/
1717
function matchesShape<T>(value: unknown, defaultValue: T): value is T {
18+
if (defaultValue === null) return value === null;
1819
if (Array.isArray(defaultValue)) return Array.isArray(value);
19-
if (defaultValue !== null && typeof defaultValue === 'object') {
20+
if (typeof defaultValue === 'object') {
2021
return typeof value === 'object' && value !== null && !Array.isArray(value);
2122
}
2223
return typeof value === typeof defaultValue;

0 commit comments

Comments
 (0)