Allow use before declaration for export= assignments#17967
Allow use before declaration for export= assignments#17967weswigham merged 1 commit intomicrosoft:masterfrom
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.
Shouldn't these test changes also come with added types and symbols baselines?
There was a problem hiding this comment.
@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. 🐱
sandersn
left a comment
There was a problem hiding this comment.
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.
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.
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.