Skip to content

fix(compiler-cli): improve error for non-exported standalone imports#67370

Open
SkyZeroZx wants to merge 1 commit intoangular:mainfrom
SkyZeroZx:fix-49874
Open

fix(compiler-cli): improve error for non-exported standalone imports#67370
SkyZeroZx wants to merge 1 commit intoangular:mainfrom
SkyZeroZx:fix-49874

Conversation

@SkyZeroZx
Copy link
Contributor

Add diagnostic when a standalone imports entry references a non-exported directive/component/pipe.

Fixes #49874

What is the current behavior?

image

Misleading message shown

Component imports must be standalone components, directives, pipes, or must be NgModules.

What is the new behavior?

image

Now language service should be show :

'Dir' is used in 'imports' but is not exported from its file. Component imports must be exported to be resolved by the Angular compiler.

@pullapprove pullapprove bot requested a review from AndrewKushnir February 28, 2026 22:04
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Feb 28, 2026
@ngbot ngbot bot added this to the Backlog milestone Feb 28, 2026
!reflector.isStaticallyExported(ref.node) && hasAngularCoreDecorator(ref.node, reflector);

const error = isDeferredImport
? makeUnknownComponentDeferredImportDiagnostic(ref, importExpr)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I understand (based on what I’ve reviewed in the code), makeUnknownComponentDeferredImportDiagnostic is used when a component is used with @defer. I’m not sure whether this diagnostic would also apply here or if it’s irrelevant

@AndrewKushnir AndrewKushnir requested review from crisbeto and removed request for AndrewKushnir March 1, 2026 16:56
Add diagnostic when a standalone imports entry references a non-exported directive/component/pipe.

Fixes angular#49874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Langage service reports an error when Importing a non-exported class in a standalone component.

2 participants