-
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(common): strict type checking for ngtemplateoutlet #48374
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
d1632be
to
0dcffbc
Compare
0dcffbc
to
5608708
Compare
a749412
to
d108fec
Compare
d108fec
to
069ab05
Compare
069ab05
to
10ee357
Compare
07357b2
to
b2caaf6
Compare
f0a8c4c
to
e78d7fd
Compare
If someone can help me understand why the pipeline is failiing at the 'install java' step, I would be able to correct it. This will be greatly appreciated. |
Hi @tomalaforge - In general, I think this change looks correct and it's a great improvement. That said, it's absolutely a breaking change since the type is more restrictive. There were several thousand build failures internally because of this (root causes are much lower since most failures are shared components). At the very least, this will need the |
e78d7fd
to
a28a08e
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.
Quick update: There were only about a total of ~30 templates needing updates internally so this is certainly feasible to land. Adding my approval now and will mark for merge when internal code has been migrated.
reviewed-for: public-api, fw-common
When we create a context to inject inside our ngTemplateOutlet, the context was declare as Object, therefore, there are no compilation error. Now if we add a context, we get error at compile type. BREAKING CHANGE: If the 'ngTemplateOutletContext' is different from the context, it will result in a compile-time error. Before the change, the following template was compiling: ```typescript interface MyContext { $implicit: string; } @component({ standalone: true, imports: [NgTemplateOutlet], selector: 'person', template: ` <ng-container *ngTemplateOutlet=" myTemplateRef; context: { $implicit: 'test', xxx: 'xxx' } "></ng-container> `, }) export class PersonComponent { myTemplateRef!: TemplateRef<MyContext>; } ``` However, it does not compile now because the 'xxx' property does not exist in 'MyContext', resulting in the error: 'Type '{ $implicit: string; xxx: string; }' is not assignable to type 'MyContext'.' The solution is either: - add the 'xxx' property to 'MyContext' with the correct type or - add '$any(...)' inside the template to make the error disappear. However, adding '$any(...)' does not correct the error but only preserves the previous behavior of the code. fix angular#43510
a28a08e
to
4df84cf
Compare
This PR was merged into the repository by commit d47fef7. |
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. |
When we create a context to inject inside our ngTemplateOutlet, the context was declare as Object, therefore, there are no compilation error.
Now if we add a context, we get error at compile type.
BREAKING CHANGE: If the 'ngTemplateOutletContext' is different from the context, it will result in a compile-time error.
Before the change, the following template was compiling:
However, it does not compile now because the 'xxx' property does not exist in 'MyContext', resulting in the error: 'Type '{ $implicit: string; xxx: string; }' is not assignable to type 'MyContext'.'
The solution is either:
fix #43510