-
Notifications
You must be signed in to change notification settings - Fork 26.5k
fix(ivy): Support selector-less directive as base classes #32125
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
Conversation
661fada
to
1a0fec6
Compare
6b87672
to
6871703
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just a couple nits. Thanks @atscott 👍
1a6a855
to
74c04cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
77a1183
to
eb5b57e
Compare
fa976cb
to
c1d68c1
Compare
@@ -299,7 +299,7 @@ export class R3TestBedCompiler { | |||
this.pendingComponents.clear(); | |||
|
|||
this.pendingDirectives.forEach(declaration => { | |||
const metadata = this.resolvers.directive.resolve(declaration) !; | |||
const metadata = this.resolvers.directive.resolve(declaration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on the change, but this seems unrelated. Did our typings change in a way that made this no longer return null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the difference is that this can actually return null
now whereas before it never would. Since we allow @Directive()
, this would return null
but before we required an object and this call would always(?) return something. The metadata
parameter of compileDirective
call two lines below now allows null
so I felt this was more accurate to what's possible instead of using the null assertion operator.
@@ -21,6 +21,11 @@ import {extractDirectiveGuards, extractReferencesFromType, readStringArrayType, | |||
export class DtsMetadataReader implements MetadataReader { | |||
constructor(private checker: ts.TypeChecker, private reflector: ReflectionHost) {} | |||
|
|||
isAbstractDirective(ref: Reference<ClassDeclaration>): boolean { | |||
const meta = this.getDirectiveMetadata(ref); | |||
return meta ? (meta.selector === null || meta.selector === '') : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly check for null
ness of meta
, don't rely on truthiness.
I think we should treat selector: ''
as an error and not allow it to be produced in the first place. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. We actually do throw errors elsewhere if you explicitly set selector: ''
bcbc3e8
to
fa23bb1
Compare
Following angular#31379, this adds support for directives without a selector to Ivy.
) Following angular#31379, this adds support for directives without a selector to Ivy. PR Close angular#32125
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Following #31379, this adds support for directives without a selector to
Ivy.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Only VE supports selector-less directives, per #31379.
Issue Number: N/A
What is the new behavior?
Ivy also supports selector-less directives
Does this PR introduce a breaking change?
Other information