Skip to content

Angular: Derive required inputs from Compodoc's own flag - #35758

Merged
valentinpalkovic merged 4 commits into
nextfrom
valentin/sb11-angular-required-derivation
Aug 6, 2026
Merged

valentinpalkovic merged 4 commits into
nextfrom
valentin/sb11-angular-required-derivation

Conversation

@valentinpalkovic

@valentinpalkovic valentinpalkovic commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #28706 (partially)

What I did

Angular components describe whether each input is required, and Storybook was ignoring that. It worked out requiredness from whether the property could be undefined instead, which is a different question. The result was that every signal-based input showed up as required in the props table, even ones with a default value.

Storybook now uses the requiredness the component actually declares. It still checks the optional marker as well, because Compodoc reports an input written as explicitly-not-required as being both required and optional at the same time, and only taking both into account gets that case right.

One related fix: a two-way binding's change event used to be marked required or not depending on the property it belongs to. Events are never required, and every other event already said so.

This does not fix everything in the linked issue. Inputs declared with the older decorator syntax and no explicit requiredness still show as required, because Compodoc does not report anything about them at all. That part has to be fixed upstream in Compodoc and is being worked on separately; once it lands, those inputs correct themselves with no further change here.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

  1. Generate an Angular sandbox: yarn task --task sandbox --start-from auto --template angular-vite/default-ts
  2. Open a component that uses signal inputs with default values and view its Docs page
  3. Confirm those inputs are no longer marked as required, while input.required() ones still are

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Declare whether manual QA will be needed for this PR during the next release, through qa:needed or qa:skip

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

Compodoc reports whether an input is required, and we never read it. We
computed requiredness from the TypeScript-optional marker instead, so every
signal input rendered as required regardless of how it was declared.

Requiredness now comes from Compodoc's flag, with the optional marker still
consulted. Both are needed: Compodoc derives its flag from the presence of the
`required` key in an `@Input({...})` argument rather than its value, so
`@Input({ required: false })` reports itself as required and optional at once,
and only requiring the two to agree keeps that case right.

A `model()` signal's synthesized change output is now always optional. It used
to inherit the requiredness of the input it derives from, which disagreed with
how every real output reads.

Plain decorator inputs still read as required. Compodoc emits neither flag for
them, which is an upstream gap; when it is fixed they correct themselves.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 798b759b-d96c-403b-b386-ebde4ac5b55e

📥 Commits

Reviewing files that changed from the base of the PR and between c88236e and 9a824d1.

📒 Files selected for processing (11)
  • code/frameworks/angular-vite/src/client/docs/__testfixtures__/doc-model/argtypes-filtered.snapshot
  • code/frameworks/angular-vite/src/client/docs/__testfixtures__/doc-model/argtypes.snapshot
  • code/frameworks/angular/src/client/docs/__testfixtures__/doc-model/argtypes-filtered.snapshot
  • code/frameworks/angular/src/client/docs/__testfixtures__/doc-model/argtypes.snapshot
  • code/lib/angular-compodoc/src/compodoc-types.ts
  • code/lib/angular-compodoc/src/extract-arg-types.test.ts
  • code/lib/angular-compodoc/src/extract-arg-types.ts
  • code/lib/docgen-harness/src/angular/__testfixtures__/signal-io/argtypes-filtered.snapshot
  • code/lib/docgen-harness/src/angular/__testfixtures__/signal-io/argtypes.snapshot
  • code/lib/docgen-harness/src/angular/__testfixtures__/signal-model/argtypes-filtered.snapshot
  • code/lib/docgen-harness/src/angular/__testfixtures__/signal-model/argtypes.snapshot

Walkthrough

Changes

Angular requiredness metadata

Layer / File(s) Summary
Requiredness contract and extraction
code/lib/angular-compodoc/src/compodoc-types.ts, code/lib/angular-compodoc/src/extract-arg-types.ts
The Property contract now supports optional optional and required flags. Argument extraction resolves both flags and marks synthesized model outputs as not required.
Requiredness extraction tests
code/lib/angular-compodoc/src/extract-arg-types.test.ts
Tests cover explicit, contradictory, missing, signal-input, decorator-input, and plain-input flag combinations.
Updated Angular argument-type fixtures
code/frameworks/angular*/src/client/docs/__testfixtures__/doc-model/*, code/lib/docgen-harness/src/angular/__testfixtures__/signal-io/*, code/lib/docgen-harness/src/angular/__testfixtures__/signal-model/*
Snapshots now mark affected Angular inputs and outputs as not required.

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@valentinpalkovic
valentinpalkovic force-pushed the valentin/sb11-angular-compodoc-package branch from 9095526 to 53f1137 Compare August 5, 2026 00:34
@valentinpalkovic valentinpalkovic added ci:normal Run our default set of CI jobs (choose this for most PRs). qa:needed Pull Requests that will need manual QA prior to release. labels Aug 5, 2026
Base automatically changed from valentin/sb11-angular-compodoc-package to next August 5, 2026 12:40
@valentinpalkovic
valentinpalkovic requested a review from a team August 5, 2026 12:40
@valentinpalkovic valentinpalkovic self-assigned this Aug 5, 2026
@storybook-app-bot

storybook-app-bot Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Package Benchmarks

Commit: cbae36d, ran on 6 August 2026 at 13:41:02 UTC

No significant changes detected, all good. 👏

@valentinpalkovic
valentinpalkovic merged commit 991596a into next Aug 6, 2026
133 of 141 checks passed
@valentinpalkovic
valentinpalkovic deleted the valentin/sb11-angular-required-derivation branch August 6, 2026 13:48
@github-actions github-actions Bot mentioned this pull request Aug 6, 2026
2 tasks done
@JReinhold JReinhold added qa:skip Pull Requests that do not need any QA. (e.g. documentation) and removed qa:needed Pull Requests that will need manual QA prior to release. labels Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

angular bug ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA. (e.g. documentation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Storybook Angular not setting required Inputs() correctly

3 participants