Skip to content

Commit d06d66c

Browse files
committed
use a local string rather than a function
1 parent 72c3bb6 commit d06d66c

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/compiler/emitter.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6096,19 +6096,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
60966096
}
60976097
}
60986098

6099-
function emitVar() {
6100-
if (languageVersion <= ScriptTarget.ES5) {
6101-
write("var ");
6102-
}
6103-
else {
6104-
write("const ");
6105-
}
6106-
}
6107-
61086099
function emitExternalImportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration) {
61096100
if (contains(externalImports, node)) {
61106101
const isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0;
61116102
const namespaceDeclaration = getNamespaceDeclarationNode(node);
6103+
const varOrConst = (languageVersion <= ScriptTarget.ES5) ? "var " : "const ";
61126104

61136105
if (modulekind !== ModuleKind.AMD) {
61146106
emitLeadingComments(node);
@@ -6117,7 +6109,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
61176109
// import x = require("foo")
61186110
// import * as x from "foo"
61196111
if (!isExportedImport) {
6120-
emitVar();
6112+
write(varOrConst);
61216113
};
61226114
emitModuleMemberName(namespaceDeclaration);
61236115
write(" = ");
@@ -6130,7 +6122,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
61306122
// import d, { x, y } from "foo"
61316123
const isNakedImport = SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
61326124
if (!isNakedImport) {
6133-
emitVar();
6125+
write(varOrConst);
61346126
write(getGeneratedNameForNode(<ImportDeclaration>node));
61356127
write(" = ");
61366128
}
@@ -6157,7 +6149,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
61576149
}
61586150
else if (namespaceDeclaration && isDefaultImport(node)) {
61596151
// import d, * as x from "foo"
6160-
emitVar();
6152+
write(varOrConst);
61616153
emitModuleMemberName(namespaceDeclaration);
61626154
write(" = ");
61636155
write(getGeneratedNameForNode(<ImportDeclaration>node));

0 commit comments

Comments
 (0)