-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(ivy): proper resolution of Enums in Component decorator #27971
fix(ivy): proper resolution of Enums in Component decorator #27971
Conversation
You can preview fe6688d at https://pr27971-fe6688d.ngbuilds.io/. |
You can preview 561dea7 at https://pr27971-561dea7.ngbuilds.io/. |
Prior to this change Component decorator was resolving `encapsulation` value a bit incorrectly, which resulted in `encapsulation: NaN` in compiled code. Now we resolve the value as Enum memeber and throw if it's not the case. As a part of this update, the `changeDetection` field handling is also added, the resolution logic is the same as the one used for `encapsulation` field.
561dea7
to
1c46268
Compare
You can preview 1c46268 at https://pr27971-1c46268.ngbuilds.io/. |
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.
Approved with one comment.
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.
Approved with two comments*
@@ -327,6 +329,24 @@ export class ComponentDecoratorHandler implements | |||
return meta; | |||
} | |||
|
|||
private _resolveEnumValue( |
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.
A couple points here.
-
I would prefer if this function didn't include actually reading
field
from theMap
. Passing the Map in just to read one field off of it seems unnecessary. Can you separate this logic? -
Return
null
and notundefined
in ngtsc code to indicate that a value is logically not set.
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.
Thanks for the review! Replies to your comments:
-
The
field
is also used in that function in the error message inthrow new FatalDiagnosticError
to indicate which field has problems. -
The
changeDetection
field inmetadata
object that we construct later in that function requires either be defined as ChangeDetectionStartegy or be undefined. I wanted to avoid additional conversion fromnull
->undefined
to satisfy the contract.
Please let me know if that works for you.
Thank you.
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 still dislike the pattern, but understand the reasoning.
-
That field (
changeDetection
onR3ComponentMetadata
) was added incorrectly - it should be non-optional and non-nullable. We should always be passing a value for it.
If you feel like fixing this in this PR, that would be awesome. If not I can do it in a followup, but please do use null
even if you have to convert it later for now.
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.
Thanks Alex! I've created additional fixup commit (28bcd6a) to add changeDetection
field only if it's not empty to satisfy the current contract. I've also created a ticket to update the code according to your proposal in followup PRs. Thank you.
You can preview f1805f3 at https://pr27971-f1805f3.ngbuilds.io/. |
You can preview 28bcd6a at https://pr27971-28bcd6a.ngbuilds.io/. |
…27971) Prior to this change Component decorator was resolving `encapsulation` value a bit incorrectly, which resulted in `encapsulation: NaN` in compiled code. Now we resolve the value as Enum memeber and throw if it's not the case. As a part of this update, the `changeDetection` field handling is also added, the resolution logic is the same as the one used for `encapsulation` field. PR Close angular#27971
…27971) Prior to this change Component decorator was resolving `encapsulation` value a bit incorrectly, which resulted in `encapsulation: NaN` in compiled code. Now we resolve the value as Enum memeber and throw if it's not the case. As a part of this update, the `changeDetection` field handling is also added, the resolution logic is the same as the one used for `encapsulation` field. PR Close angular#27971
…27971) Prior to this change Component decorator was resolving `encapsulation` value a bit incorrectly, which resulted in `encapsulation: NaN` in compiled code. Now we resolve the value as Enum memeber and throw if it's not the case. As a part of this update, the `changeDetection` field handling is also added, the resolution logic is the same as the one used for `encapsulation` field. PR Close angular#27971
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. |
Prior to this change Component decorator was resolving
encapsulation
value a bit incorrectly, which resulted inencapsulation: NaN
in compiled code. Now we resolve the value as Enum member and throw if it's not the case. As a part of this update, thechangeDetection
field handling is also added, the resolution logic is the same as the one used forencapsulation
field.This PR resolves issue FW-722.
PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?