Skip to content

In JS, fix crash with in a file with conflicting ES2015/commonjs exports #24960

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
merged 2 commits into from
Jun 14, 2018

Conversation

sandersn
Copy link
Member

Previously, the binder would try to bind commonjs module.exports even if the file was known to be an ES2015 module. This caused a crash in the checker when it tried to check the export symbol as a value.

Fixes #24934

@sandersn sandersn requested review from a user and mhegazy June 14, 2018 17:01
@@ -2345,7 +2349,9 @@ namespace ts {
}

// 'module.exports = expr' assignment
setCommonJsModuleIndicator(node);
if (!setCommonJsModuleIndicator(node)) {
Copy link

Choose a reason for hiding this comment

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

Nit: The code was this way before, but this is a case of:

if (something) {
    foo();
    return;
}

foo();
doSomethingElse();

The if (!setCommonJsModuleIndicator(node)) { return; } could be moved up before if (isEmptyObjectLiteral(assignedExpression) ... to avoid this duplication.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Fixed.

@sandersn sandersn merged commit a56b272 into master Jun 14, 2018
@sandersn sandersn deleted the js/fix-crash-for-conflicting-es2015-commonjs branch June 14, 2018 18:18
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.

1 participant