Skip to content

[BUGFIX] Add assertion for invalid component helper argument#21406

Open
olenderhub wants to merge 2 commits into
emberjs:mainfrom
olenderhub:bugfix-component-helper-strict-mode-assertion
Open

[BUGFIX] Add assertion for invalid component helper argument#21406
olenderhub wants to merge 2 commits into
emberjs:mainfrom
olenderhub:bugfix-component-helper-strict-mode-assertion

Conversation

@olenderhub
Copy link
Copy Markdown
Contributor

Fixes #18072

Adds a debug assertion in the dynamic component resolution opcode to throw a useful error when the {{component}} helper receives an invalid argument type, e.g. an object, instead of failing with a cryptic error.

Adds a test to verify the assertion fires with the expected message.

Tested with:

  • pnpm test:wip

typeof component === 'string' ||
isCurriedValue(component) ||
((typeof component === 'object' || typeof component === 'function') &&
hasInternalComponentManager(component)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had to double check this because hasInternalComponentManager is misleadingly named -- this is what we want and would work with 3rd-party component managers

isCurriedValue(component) ||
((typeof component === 'object' || typeof component === 'function') &&
hasInternalComponentManager(component)),
'The `{{component}}` helper received an invalid value. It expects a component definition, or a string component name in non-strict mode.'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like on line 168 above we know if we are in strict mode or not, so we can change this message to be a bit more precise based on isStrict

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

I think this is pretty close! just one last thing

@olenderhub
Copy link
Copy Markdown
Contributor Author

I added improvements @NullVoxPopuli please check it

@olenderhub
Copy link
Copy Markdown
Contributor Author

@NullVoxPopuli sorry I see still some errors, checking it

@olenderhub olenderhub force-pushed the bugfix-component-helper-strict-mode-assertion branch from 7d7a8b2 to 94d6e6c Compare May 29, 2026 23:42
@olenderhub
Copy link
Copy Markdown
Contributor Author

@NullVoxPopuli I believe now is ready to review again. Please check it

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.

Unreachable code "reached" when trying to render a non-string with the component helper

2 participants