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

Elide re-exports of unresolved type-only imports #56449

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Conversation

andrewbranch
Copy link
Member

Fixes #56445

@andrewbranch andrewbranch marked this pull request as ready for review November 17, 2023 20:01
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Nov 17, 2023
@@ -47581,7 +47581,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
if (target === unknownSymbol) {
return true;
return !excludeTypeOnlyValues || !getTypeOnlyAliasDeclaration(symbol);
Copy link
Member

Choose a reason for hiding this comment

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

Does this need a test for the other condition? I think the test covers the latter only.

Copy link
Member Author

Choose a reason for hiding this comment

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

!excludeTypeOnlyValues is never covered under any test because I’m pretty sure it’s never correct to pass false for that. I fixed one case that forgot to pass true for it in #55097, and the last remaining caller didn’t change any baselines when I had it pass true. I made a note to look at it and probably remove the parameter altogether in a follow-up PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, the last place that doesn’t pass true is checking whether to elide an ImportEqualsDeclaration, which doesn’t strictly matter because it’s not a runtime error to require() a module that doesn’t export anything. But it should probably be elided anyway, so it’s likely that parameter will go away and we’ll treat it as if it’s always true.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, thanks!

@andrewbranch
Copy link
Member Author

@typescript-bot cherry-pick this to release-5.3

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 17, 2023

Heya @andrewbranch, I've started to run the task to cherry-pick this into release-5.3 on this PR at c8f2cc7. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @andrewbranch, I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-5.3 manually.

@andrewbranch andrewbranch merged commit 4d34182 into main Nov 17, 2023
19 checks passed
@andrewbranch andrewbranch deleted the bug/56445 branch November 17, 2023 22:38
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid JavaScript output with re-exported unresolved import types (regression)
3 participants