Skip to content

Commit c21ff64

Browse files
committed
[Transforms] fix8038 and 8047 (microsoft#8071)
* Fix 8047: stop "require" is paranthesized * Fix 8038: quote "default" in es3 output
1 parent 2c95ea9 commit c21ff64

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/compiler/transformers/module/module.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,20 @@ namespace ts {
755755
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
756756
const name = (<ImportSpecifier>declaration).propertyName
757757
|| (<ImportSpecifier>declaration).name;
758-
return createPropertyAccess(
759-
getGeneratedNameForNode(declaration.parent.parent.parent),
760-
getSynthesizedClone(name),
761-
/*location*/ node
762-
);
758+
if (name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion <= ScriptTarget.ES3) {
759+
return createElementAccess(
760+
getGeneratedNameForNode(declaration.parent.parent.parent),
761+
createLiteral(name.text),
762+
/*location*/ node
763+
);
764+
}
765+
else {
766+
return createPropertyAccess(
767+
getGeneratedNameForNode(declaration.parent.parent.parent),
768+
getSynthesizedClone(name),
769+
/*location*/ node
770+
);
771+
}
763772
}
764773
}
765774
}
@@ -791,7 +800,7 @@ namespace ts {
791800

792801
function createExportAssignment(name: Identifier, value: Expression) {
793802
return createAssignment(
794-
name.originalKeywordKind && languageVersion === ScriptTarget.ES3
803+
name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion === ScriptTarget.ES3
795804
? createElementAccess(
796805
createIdentifier("exports"),
797806
createLiteral(name.text)

0 commit comments

Comments
 (0)