Issue: dock-layout Library TypeScript Build Errors
Pre-existing strict null check errors prevent gograb-dev from building for production
Issue: dock-layout Library TypeScript Build Errors
Summary
The libs/libs-ui/dock-layout library has 30+ TypeScript strict null check errors that prevent the unified-builder library (and transitively, gograb-dev) from building in production mode. This blocks Cloudflare Pages deployment of the gograb-dev app.
Build Failure Chain
gograb-dev:build:production
└── unified-builder:build:production ← FAILS HERE
└── dock-layout (TypeScript compilation errors)
Error Categories
1. Object Possibly Undefined (TS2532 / TS18048) -- ~25 errors
Variables that could be undefined are used without null checks.
Affected files:
dock-split.component.ts(3 errors, lines 194-200)dock-drag.service.ts(5 errors, lines 593-614)dock-layout.service.ts(3 errors, lines 422-523)dock-state.service.ts(3 errors, lines 607-610, 986-1004)hit-testing.utils.ts(1 error, line 123)layout-tree.utils.ts(20+ errors, lines 220-403)
Example:
// TS18048: 'parent' is possibly 'undefined'
parent.children // needs: parent?.children or parent!.children
2. Property Does Not Exist on Type (TS2339) -- ~8 errors
Accessing properties on discriminated union types without narrowing.
Affected files:
dock-state.service.ts(lines 607-612) -- accessingtabsNodeId,activeTabIndex,tabs,previousIndexon typeneverlayout-tree.utils.ts(multiple) -- accessingchildrenandtabsonLayoutNodeunion type
Example:
// TS2339: Property 'children' does not exist on type 'LayoutNode'
// Property 'children' does not exist on type 'TabsLayoutNode'
parent.children // needs type narrowing: if ('children' in parent)
3. Type Assignability (TS2322 / TS2345 / TS2538) -- ~10 errors
Return types or argument types don't match expected types.
Affected files:
dock-keyboard.service.ts(line 271) --string | undefinednot assignable tostring | nulldock-layout.service.ts(line 523) --string | undefinednot assignable tostringlayout-builder.utils.ts(line 385) --undefinedused as index typelayout-tree.utils.ts(multiple) -- spread objects missing required properties
Recommended Fix Strategy
Option A: Targeted Null Checks (Recommended)
Add proper null guards and type narrowing where needed. This is the safest approach.
// Before
const idx = parent.children.indexOf(nodeId);
// After
if (!parent || !('children' in parent)) return;
const idx = parent.children.indexOf(nodeId);
Option B: Non-null Assertions (Quick Fix)
Use ! operator where the value is guaranteed by runtime logic but TypeScript can't infer it.
// Before
parent.children // TS error
// After
parent!.children // suppresses error
Option C: Disable Strict Null Checks for Library (Not Recommended)
Could add "strictNullChecks": false to the library's tsconfig, but this hides real bugs.
File Inventory
| File | Errors | Primary Issue |
|---|---|---|
layout-tree.utils.ts |
30+ | Undefined parents, union type narrowing |
dock-state.service.ts |
7 | Type never access, undefined params |
dock-drag.service.ts |
5 | Undefined tab references |
dock-split.component.ts |
3 | Undefined object access |
dock-layout.service.ts |
3 | Undefined + type assignability |
dock-keyboard.service.ts |
1 | undefined vs null mismatch |
hit-testing.utils.ts |
1 | Undefined access |
layout-builder.utils.ts |
1 | Undefined as index |
Resolution (Session 103)
All 30+ TypeScript strict null check errors were fixed across 8 files. The errors surfaced during production builds because the custom Angular library builder compiles with stricter settings than the default tsconfig.base.json.
Fix Strategy
The fixes applied targeted null safety without changing runtime behavior:
- Non-null assertions (
!) — where array access is guaranteed by loop bounds or prior length checks (e.g.,registeredTabs[0]!,stack[stack.length - 1]!afterif (stack.length === 0) return) - Nullish coalescing (
??) — for safe fallback values (e.g.,resizeStartSizes[index] ?? 0) - Optional chaining (
?.) — for map lookups that may return undefined (e.g.,state.nodes[id]?.type) - Type guard filters — replacing
.filter(Boolean)with.filter((n): n is LayoutNode => !!n)for proper type narrowing - Null checks on parent lookups — adding
if (parent && parent.type === 'split')instead of justif (parent.type === 'split')throughoutlayout-tree.utils.ts - Type assertions (
as LayoutNode) — for spread operations that lose discriminated union type info
Files Fixed (8 total)
| File | Errors Fixed | Fix Type |
|---|---|---|
dock-split.component.ts |
3 | ?? fallback, ! assertion |
dock-drag.service.ts |
5 | ! on loop-bounded array access |
dock-keyboard.service.ts |
1 | ?? '' fallback |
dock-layout.service.ts |
3 | ?. optional chaining, ! assertion |
dock-state.service.ts |
2 | ! after length guard |
hit-testing.utils.ts |
1 | ! on guaranteed array element |
layout-builder.utils.ts |
1 | Conditional index access |
layout-tree.utils.ts |
~20 | Null checks, type guards, as casts |
Build Verification
nx build unified-builder --configuration=production— passesyarn deploy:wrangler:dev— deployed successfully (312 files, HTTP 200)
Impact
- gograb-dev production build is fully unblocked
- gograb-dev deployed to Cloudflare Pages at
gograb-dev-app.pages.dev - All strict null check errors in the dock-layout library are resolved
Related
- Cloudflare deployment status: see
cloudflare-deployment-status.mdin this session - The dock-layout library is part of
libs/libs-ui/dock-layout/ - The unified-builder library at
libs/libs-space/unified-builder/depends on dock-layout