Skip to content

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

Merged

Conversation

weswigham
Copy link
Member

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.

@mhegazy
Copy link
Contributor

mhegazy commented Aug 22, 2017

We should port this to release-2.5 as well.

@weswigham weswigham force-pushed the allow-export-before-declaration-in-ts branch from 8759eb9 to f4b4c3d Compare August 22, 2017 19:43
@@ -1,17 +0,0 @@
tests/cases/compiler/exportAssignmentOfGenericType1_0.ts(1,10): error TS2449: Class 'T' used before its declaration.
Copy link
Member

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?

Copy link
Member Author

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. 🐱

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😿

@weswigham weswigham merged commit bdc2aa8 into microsoft:master Aug 22, 2017
@weswigham weswigham deleted the allow-export-before-declaration-in-ts branch August 22, 2017 20:48
Copy link
Member

@sandersn sandersn left a 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
Copy link
Member

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.

Copy link
Member Author

@weswigham weswigham Aug 22, 2017

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.

weswigham added a commit to weswigham/TypeScript that referenced this pull request Aug 22, 2017
weswigham added a commit that referenced this pull request Aug 23, 2017
* Allow use before declaration for export= assignments (#17967)

* Add release-2.5 to covered branches
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants