mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
Fix 6 more warnings (unnecessary conditions and nullish coalescing)
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@ export async function getComponentHierarchy(): Promise<Record<string, ComponentN
|
||||
hierarchy[node.id] = {
|
||||
id: node.id,
|
||||
type: node.type,
|
||||
parentId: node.parentId !== null && node.parentId !== undefined ? node.parentId : undefined,
|
||||
parentId: node.parentId ?? undefined,
|
||||
childIds: JSON.parse(node.childIds) as string[],
|
||||
order: node.order,
|
||||
pageId: node.pageId,
|
||||
|
||||
@@ -19,22 +19,22 @@ const PACKAGE_COMPONENT_REGISTRY: Record<string, Record<string, ComponentDef>> =
|
||||
* and a `components` array (or object) with component definitions.
|
||||
*/
|
||||
export function loadPackageComponents(packageContent: JsonValue): void {
|
||||
if (packageContent === null || packageContent === undefined || typeof packageContent !== 'object') return
|
||||
if (typeof packageContent !== 'object' || packageContent === null) return
|
||||
|
||||
const pkg = packageContent as JsonObject
|
||||
const metadata = pkg?.metadata
|
||||
const metadata = pkg.metadata
|
||||
const packageId =
|
||||
(metadata !== null && metadata !== undefined && typeof metadata === 'object' && !Array.isArray(metadata)
|
||||
? (metadata as JsonObject)['packageId']
|
||||
: undefined) ??
|
||||
pkg?.['package'] ??
|
||||
pkg?.['packageId']
|
||||
pkg['package'] ??
|
||||
pkg['packageId']
|
||||
if (packageId === null || packageId === undefined || typeof packageId !== 'string') return
|
||||
|
||||
const compsArray: JsonValue[] =
|
||||
Array.isArray(pkg.components) && pkg.components.length > 0
|
||||
? pkg.components
|
||||
: Array.isArray((pkg.ui as JsonObject)?.components)
|
||||
: Array.isArray((pkg.ui as JsonObject | undefined)?.components)
|
||||
? ((pkg.ui as JsonObject).components as JsonValue[])
|
||||
: []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user