From c21ff6421cff8896358a0f134965c4fabbe215c2 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 14 Apr 2016 09:30:19 -0700 Subject: [PATCH] [Transforms] fix8038 and 8047 (#8071) * Fix 8047: stop "require" is paranthesized * Fix 8038: quote "default" in es3 output --- src/compiler/transformers/module/module.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 563733a9c97..83604946102 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -755,11 +755,20 @@ namespace ts { else if (declaration.kind === SyntaxKind.ImportSpecifier) { const name = (declaration).propertyName || (declaration).name; - return createPropertyAccess( - getGeneratedNameForNode(declaration.parent.parent.parent), - getSynthesizedClone(name), - /*location*/ node - ); + if (name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion <= ScriptTarget.ES3) { + return createElementAccess( + getGeneratedNameForNode(declaration.parent.parent.parent), + createLiteral(name.text), + /*location*/ node + ); + } + else { + return createPropertyAccess( + getGeneratedNameForNode(declaration.parent.parent.parent), + getSynthesizedClone(name), + /*location*/ node + ); + } } } } @@ -791,7 +800,7 @@ namespace ts { function createExportAssignment(name: Identifier, value: Expression) { return createAssignment( - name.originalKeywordKind && languageVersion === ScriptTarget.ES3 + name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion === ScriptTarget.ES3 ? createElementAccess( createIdentifier("exports"), createLiteral(name.text)