-
Notifications
You must be signed in to change notification settings - Fork 12.9k
fix(37165): Cannot read property 'flags' of undefined #37228
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
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.
globalObjectType
is the type for Object
and should not be undefined
under normal circumstances. We should probably fix that instead of covering over the problem.
It's possible that it's undefined in some situations, but in that case, other uses of getGlobalType
need to consider this possibility, and the situation needs to be documented, probably on the declaration of getGlobalType
.
@sandersn Thanks for the feedback. 👍 The
As I remember correctly the chain which causes the crash looks like so I'll check maybe need to throw error earlier without checking to existence |
Looked into this and it turns out this happens because of export as namespace and module agumentations.In the repro when trying to create new merged global of Bar we need to resolve what it is (which results in finding Bar from foo) but this happens before global object type and others are calculated resulting in accessing globalObjectType (because Foo doesn't have Bar so we are trying to figure out if its from global object type). This raises question of all these globalTypes that we calculate being accessed before and needs to be thought through? Note that we have similar situation which does get guarded unintentionall... but using undefined instead of getting correct globalObjectType would mean that we would report error which is questionable? In repro scenario we would get this error, but if we comment our Bar declaration from the global we wouldn't.
|
@sheetalkamat Thanks for the detailed feedback 👍. What solution do you think is acceptable for this issue? |
@ahejlsberg @weswigham @RyanCavanaugh @DanielRosenwasser to comment on what to do when hitting globalObject type before its populated (during module augmentation where the global*types are not yet calculated but module augmentation might use them) |
I think the right thing is to report an error and see what breaks in test suites, and ask partner teams to try it out. |
@a-tarasyuk can you try reporting an error, and then we'll pass this build on to some partners if the results on our tests are good? |
Fixes #37165