Skip to content
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

Fix shadowed global detection to ignore declarations in type tokens #809

Merged
merged 1 commit into from Jul 13, 2023

Conversation

alangpierce
Copy link
Owner

Fixes #808

All identifier tokens, including type tokens, have a role assigned by the parser that indicates whether they're a declaration, usage, etc, and even for type tokens this is important for TS automatic export elision. When identifying shadowed globals, though, only non-type declarations should be considered. This fixes an issue where parameters within TS function types were inadvertently being treated as declarations.

Fixes #808

All identifier tokens, including type tokens, have a role assigned by the parser
that indicates whether they're a declaration, usage, etc, and even for type
tokens this is important for TS automatic export elision. When identifying
shadowed globals, though, only non-type declarations should be considered. This
fixes an issue where parameters within TS function types were inadvertently
being treated as declarations.
@github-actions
Copy link

Benchmark results

Before this PR: 319.7 thousand lines per second
After this PR: 312.3 thousand lines per second

Measured change: 2.33% slower (4.11% slower to 0.87% slower)
Summary: Probably slower

@alangpierce alangpierce merged commit 7bd7ca3 into main Jul 13, 2023
6 checks passed
@alangpierce alangpierce deleted the fix-shadowed-globals-with-ts-function-types branch July 13, 2023 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect elision of named import if typings of a callback function contains a parameter with the same name
1 participant