-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Allow use before declaration for export= assignments #17967
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
Allow use before declaration for export= assignments #17967
Conversation
We should port this to release-2.5 as well. |
8759eb9
to
f4b4c3d
Compare
@@ -1,17 +0,0 @@ | |||
tests/cases/compiler/exportAssignmentOfGenericType1_0.ts(1,10): error TS2449: Class 'T' used before its 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.
Shouldn't these test changes also come with added types and symbols baselines?
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.
@sandersn They would - if they weren't already sitting in the folder and correct, because they never got removed when the .errors
baselines started being written whenever this behavior was first changed. 🐱
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.
😿
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.
Couple of follow-up comments
// export specifiers do not use the variable, they only make it available for use | ||
return true; | ||
} | ||
// When resolving symbols for exports, the `usage` location passed in can be the export site directly |
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.
Could the caller normalize the provided location instead of forcing the code to add special cases? The rest of the code might need to add the parent/non-parent dual checks.
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.
Ehh, I don't really like the idea of special casing it in checkResolvedBlockScopedVariable
, since its only looking up the declaration associated with a symbol and handing it off; it'd have to have the same special-casey logic as here (well, it'd have to dive down rather than walk up). Except we already to special-case things here, and not in checkResolvedBlockScopedVariable
.
When we started including export assignments in use before declaration checks, we did not include an exception for
export=
kinds (the TS construct). It is appropriate to have an exception as the export statement is moved to after the declaration, so no TDZ error could exist at runtime.This fixes a large break in one of the projects in our RWC suite.