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(core): ensure all initializer functions run in an injection context #54761
Conversation
fbfb314
to
493b515
Compare
// non-required query results are undefined before we run creation mode on the view queries | ||
const appCmpt = new AppComponent(); | ||
expect(appCmpt.divEl()).toBeUndefined(); | ||
it('should return undefined if optional query is read in the constructor', () => { |
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 had to rework these tests, because they were instantiating components manually.
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. Only would optionally suggest TestBed.runInInjectionContext
for shorter tests
@Component({template: ''}) | ||
class TestCmp { | ||
input = input<number>(0); | ||
} |
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.
TestBed.runInInjectionContext(() => input(0))
also works and is shorter.
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.
Good point, I'll change the input tests but will keep the query tests as they are since they're kinda tied to a view.
Ensures that all of the functions intended to be run in initializers are in an injection context. This is a stop-gap until we have a compiler diagnostic for it.
493b515
to
31bfdb3
Compare
Blocked on reworking internal targets that are using the functions incorrectly. |
Passing TGP, excluding some flakes and after I land a separate cleanup CL. |
This PR was merged into the repository by commit 018f826. |
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. |
Ensures that all of the functions intended to be run in initializers are in an injection context. This is a stop-gap until we have a compiler diagnostic for it.