-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Move to file: fix detection of references to globals that shouldn't be moved #60450
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…t imported in the file
…vetofile-global
typescript-bot
added
For Milestone Bug
PRs that fix a bug with a specific milestone
labels
Nov 7, 2024
andrewbranch
changed the title
Bug/59799
Move to file: fix detection of references to globals that shouldn't be moved
Nov 7, 2024
iisaduan
approved these changes
Nov 15, 2024
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.
👍
@typescript-bot cherry-pick to release-5.7 |
typescript-bot
pushed a commit
that referenced
this pull request
Nov 15, 2024
…e moved (#60450) Co-authored-by: Isabel Duan <isabelduan@microsoft.com> Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Hey, @andrewbranch! I've created #60513 for you. |
DanielRosenwasser
pushed a commit
that referenced
this pull request
Nov 18, 2024
…e-5.7 (#60513) Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com> Co-authored-by: Isabel Duan <isabelduan@microsoft.com> Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #59799
Fixes #60408
Closes #60173
Closes #60410
isGlobalType
was a red herring; it was implemented incorrectly but it never mattered if something was a global type. What we actually care about is whether the thing we’re moving was merging with declarations in other files. If we check that after ruling out that it was in an import, then it must be a global, and if the thing has a global definition in another file, we can’t start exporting it without breaking that merge:Why don’t we want to export
interface String
when we move the prototype method definition here?String.prototype...
refers to a value whileinterface String
refers to a type—this feels important, but they’re actually two different meanings of the same symbol!String
is a global type—if we had instead writteninterface Foo {}
and moved the codetype Bar = Foo
, it would be true thatFoo
is a global type, but we make an assumption that most people want modules most of the time, and it’s probably a coincidence that they hadn’t made this file a module yet. In this case, we would actually start exportinginterface Foo {}
, converting it from a global type to an exported type. (Also, the same argument can be made for values, so being a type has nothing to do with it.)String
from a global to an export by making modifications in this file alone—there are other definitions ofString
in other files, which increases our confidence that it’s actually intended to be a global.