Skip to content

fix(render): strip undeclared inputs in NgComponentOutlet (NG0303 silence)#368

Merged
blove merged 1 commit into
mainfrom
claude/post-fixes-local-test
May 16, 2026
Merged

fix(render): strip undeclared inputs in NgComponentOutlet (NG0303 silence)#368
blove merged 1 commit into
mainfrom
claude/post-fixes-local-test

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 16, 2026

Summary

RenderElement passes 5 framework-only inputs to every component it mounts (bindings, emit, loading, childKeys, spec) plus user-defined props from the spec. Angular dev mode raises NG0303 for every key the target component doesn't declare. Live measurement on the chat-generative-ui dashboard: ~100 errors per turn.

Breakdown of the 100 errors per dashboard turn:

  • ~25 from the brief skeleton phase — DefaultFallbackComponent declares zero inputs and rejects all of them
  • ~75 from user view components (DashboardGrid, Container, StatCard, LineChart, BarChart, DataGrid) that don't declare the 5 framework keys

Fix

Filter resolvedInputs via reflectComponentType() before passing to ngComponentOutlet. Cache the declared-input set per component class via a WeakMap.

The key correctness call: distinguish "0 declared inputs" (filter all keys) from "no metadata available" (pass-through). The naive check if (declared.size === 0) return inputs treats DefaultFallbackComponent as no-metadata and keeps spamming. The fix stores null vs Set in the cache and only short-circuits on null.

Test plan

  • pnpm nx run cockpit-chat-generative-ui-angular:build — clean
  • Chrome MCP after fix: 0 NG0303 errors per dashboard turn (was ~100), all 4 stat cards / 2 charts / 1 grid render correctly
  • CI: Library — lint / test / build

Files

  • libs/render/src/lib/render-element.component.ts — add getDeclaredInputs() + filterInputsForClass() helpers, wire into both non-repeat and repeat input paths

🤖 Generated with Claude Code

RenderElement passes 5 framework-only inputs to every mounted component
(bindings, emit, loading, childKeys, spec), plus any user-defined props
from the spec. Angular dev mode raises NG0303 for any key the target
component doesn't declare — measured ~100 errors per dashboard turn:
~25 from the brief skeleton phase (DefaultFallbackComponent declares
zero inputs and rejects all of them) and ~75 from user view components
that don't declare the framework keys.

Filter via reflectComponentType() before passing to ngComponentOutlet:
- Reflection succeeded → pass only the keys the component declares
- Reflection failed (uncompiled / non-component) → pass-through

The distinction between "0 declared inputs" (filter all) and "no
metadata available" (pass-through) is important — naive `.size === 0`
treats DefaultFallbackComponent as no-metadata and keeps the spam.

Verified via chrome MCP: 0 NG0303 errors per dashboard turn (was ~100),
all 4 stat cards / 2 charts / 1 grid still render correctly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 16, 2026 5:16pm

Request Review

@blove blove merged commit 7f927f1 into main May 16, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant