Skip to content

Angular: switch ɵReflectionCapabilities -> reflectComponentType in NgComponentAnalyzer #30954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: next
Choose a base branch
from

Conversation

vasimi
Copy link

@vasimi vasimi commented Mar 27, 2025

What I did

Replaced ɵReflectionCapabilities with reflectComponentType in NgComponentAnalyzer wherever possible. ɵReflectionCapabilities does not return input/output signals, which is causing Storybook to set values directly to the component properties instead of updating them as inputs.

It doesn't have any actual benefit in isStandaloneComponent, but it felt better to use a documented API instead of something internal. In this function, I also removed the comment mentioning Angular < 14, since storybook already dropped support of versions that old.

reflectComponentType is supported in Angular 15, the oldest version supported by Storybook.

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

storybookjs/sandboxes#13

  1. Build a static version of the angular-cli/default-ts template
  2. Open Storybook in your browser
  3. Access Header story, modify input value

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

  • 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.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

This PR migrates the Angular component analyzer to use reflectComponentType instead of the internal ɵReflectionCapabilities, ensuring correct input/output signal extraction and updating related tests.

• Updated /code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.ts to safely call reflectComponentType(component)?.isStandalone.
• Adjusted /code/frameworks/angular/src/client/angular-beta/utils/NgComponentAnalyzer.test.ts to verify the new extraction behavior.
• Removed outdated Angular <14 comments from the isStandaloneComponent logic.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@vasimi vasimi changed the title fix: switch ɵReflectionCapabilities -> reflectComponentType in NgComponentAnalyzer Angular: switch ɵReflectionCapabilities -> reflectComponentType in NgComponentAnalyzer Mar 27, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Michal Vasicek and others added 2 commits March 27, 2025 19:38
…onentAnalyzer where possible, cover with unit tests
…entAnalyzer.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@vasimi vasimi force-pushed the switch-angular-io-to-reflectComponentType branch from 48c3b38 to c01815e Compare March 27, 2025 18:38
@valentinpalkovic valentinpalkovic self-assigned this Mar 28, 2025
@valentinpalkovic
Copy link
Contributor

Hi @vasimi

Thank you for putting together the PR! Great stuff.

Can you describe with some examples or create a GitHub issue of what the PR concretely fixes?

Copy link

nx-cloud bot commented Mar 31, 2025

View your CI Pipeline Execution ↗ for commit c456bbe.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 38s View ↗

☁️ Nx Cloud last updated this comment at 2025-04-02 21:14:53 UTC

@vasimi
Copy link
Author

vasimi commented Apr 2, 2025

While switching to reflectComponentType resolved the issue in my environment, I'm not able to come up with an example that would be broken in the same way as the actual code where I encountered this issue is (which I unfortunately cannot share) and even reflectComponentType apparently doesn't solve the issue in Storybook's unit tests (which would be failing before if signal inputs were tested at all).

I'll be digging deeper into Angular and I'll try to get to the bottom of this.

@valentinpalkovic
Copy link
Contributor

Hi @vasimi

Can you take a look at the unit tests? https://app.circleci.com/pipelines/github/storybookjs/storybook/97236/workflows/ef65b294-8e52-4a3d-b325-0137255cbd72/jobs/817727

Some attributes are applied twice.

@valentinpalkovic
Copy link
Contributor

Hi @vasimi,

I have left a comment recently. Can you take a look? If you don't have enough free capacity left, I can take a look at it at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants