Merge pull request #6597 from plantain-00/use_const_rather_than_var_when_target_es6
Use const rather than var when target es6
This commit is contained in:
commit
6ff1bbee4c
|
@ -6100,6 +6100,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
if (contains(externalImports, node)) {
|
||||
const isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0;
|
||||
const namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
const varOrConst = (languageVersion <= ScriptTarget.ES5) ? "var " : "const ";
|
||||
|
||||
if (modulekind !== ModuleKind.AMD) {
|
||||
emitLeadingComments(node);
|
||||
|
@ -6107,7 +6108,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
if (namespaceDeclaration && !isDefaultImport(node)) {
|
||||
// import x = require("foo")
|
||||
// import * as x from "foo"
|
||||
if (!isExportedImport) write("var ");
|
||||
if (!isExportedImport) {
|
||||
write(varOrConst);
|
||||
};
|
||||
emitModuleMemberName(namespaceDeclaration);
|
||||
write(" = ");
|
||||
}
|
||||
|
@ -6119,7 +6122,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
// import d, { x, y } from "foo"
|
||||
const isNakedImport = SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
|
||||
if (!isNakedImport) {
|
||||
write("var ");
|
||||
write(varOrConst);
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>node));
|
||||
write(" = ");
|
||||
}
|
||||
|
@ -6146,7 +6149,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
}
|
||||
else if (namespaceDeclaration && isDefaultImport(node)) {
|
||||
// import d, * as x from "foo"
|
||||
write("var ");
|
||||
write(varOrConst);
|
||||
emitModuleMemberName(namespaceDeclaration);
|
||||
write(" = ");
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>node));
|
||||
|
|
|
@ -24,7 +24,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
step((generator = generator.call(thisArg, _arguments)).next());
|
||||
});
|
||||
};
|
||||
var task_1 = require("./task");
|
||||
const task_1 = require("./task");
|
||||
class Test {
|
||||
example() {
|
||||
return __awaiter(this, void 0, task_1.Task, function* () { return; });
|
||||
|
|
|
@ -31,16 +31,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.default = {};
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_1.js]
|
||||
"use strict";
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
const es6ImportDefaultBindingFollowedWithNamedImport_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_1.a;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
const es6ImportDefaultBindingFollowedWithNamedImport_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_2.a;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
const es6ImportDefaultBindingFollowedWithNamedImport_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.x;
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.a;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
const es6ImportDefaultBindingFollowedWithNamedImport_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_4.x;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
const es6ImportDefaultBindingFollowedWithNamedImport_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_5.m;
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this
|
|||
exports.a = 10;
|
||||
//// [es6ImportNameSpaceImport_1.js]
|
||||
"use strict";
|
||||
var nameSpaceBinding = require("./es6ImportNameSpaceImport_0");
|
||||
const nameSpaceBinding = require("./es6ImportNameSpaceImport_0");
|
||||
var x = nameSpaceBinding.a;
|
||||
|
||||
|
||||
|
|
|
@ -53,26 +53,26 @@ exports.z2 = 10;
|
|||
exports.aaaa = 10;
|
||||
//// [es6ImportNamedImport_1.js]
|
||||
"use strict";
|
||||
var es6ImportNamedImport_0_1 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_1 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_1.a;
|
||||
var es6ImportNamedImport_0_2 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_2 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_2.a;
|
||||
var es6ImportNamedImport_0_3 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_3 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_3.x;
|
||||
var xxxx = es6ImportNamedImport_0_3.a;
|
||||
var es6ImportNamedImport_0_4 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_4 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_4.x;
|
||||
var es6ImportNamedImport_0_5 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_5 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_5.m;
|
||||
var es6ImportNamedImport_0_6 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_6 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_6.a1;
|
||||
var xxxx = es6ImportNamedImport_0_6.x1;
|
||||
var es6ImportNamedImport_0_7 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_7 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_7.a1;
|
||||
var xxxx = es6ImportNamedImport_0_7.x1;
|
||||
var es6ImportNamedImport_0_8 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_8 = require("./es6ImportNamedImport_0");
|
||||
var z111 = es6ImportNamedImport_0_8.z1;
|
||||
var es6ImportNamedImport_0_9 = require("./es6ImportNamedImport_0");
|
||||
const es6ImportNamedImport_0_9 = require("./es6ImportNamedImport_0");
|
||||
var z2 = es6ImportNamedImport_0_9.z2; // z2 shouldn't give redeclare error
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ export = a;
|
|||
exports.a = 10;
|
||||
//// [es6ImportNamedImportInExportAssignment_1.js]
|
||||
"use strict";
|
||||
var es6ImportNamedImportInExportAssignment_0_1 = require("./es6ImportNamedImportInExportAssignment_0");
|
||||
const es6ImportNamedImportInExportAssignment_0_1 = require("./es6ImportNamedImportInExportAssignment_0");
|
||||
module.exports = es6ImportNamedImportInExportAssignment_0_1.a;
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ exports.M = t1_1.M;
|
|||
exports.a = t1_1.a;
|
||||
//// [t3.js]
|
||||
"use strict";
|
||||
var t1_1 = require("./t1");
|
||||
const t1_1 = require("./t1");
|
||||
exports.v = t1_1.v;
|
||||
exports.f = t1_1.f;
|
||||
exports.C = t1_1.C;
|
||||
|
|
|
@ -24,6 +24,6 @@ exports.y = t1_1.x;
|
|||
exports.x = t1_1.y;
|
||||
//// [t3.js]
|
||||
"use strict";
|
||||
var t1_1 = require("./t1");
|
||||
const t1_1 = require("./t1");
|
||||
exports.y = t1_1.x;
|
||||
exports.x = t1_1.y;
|
||||
|
|
|
@ -69,7 +69,7 @@ exports.M = t1_1.M1;
|
|||
exports.a = t1_1.a1;
|
||||
//// [t3.js]
|
||||
"use strict";
|
||||
var t1_1 = require("./t1");
|
||||
const t1_1 = require("./t1");
|
||||
exports.v = t1_1.v1;
|
||||
exports.f = t1_1.f1;
|
||||
exports.C = t1_1.C1;
|
||||
|
|
|
@ -45,24 +45,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.default = "hello";
|
||||
//// [t3.js]
|
||||
"use strict";
|
||||
var a = require("./t1");
|
||||
const a = require("./t1");
|
||||
exports.a = a;
|
||||
a.default;
|
||||
var t1_1 = require("./t1");
|
||||
const t1_1 = require("./t1");
|
||||
exports.b = t1_1.default;
|
||||
t1_1.default;
|
||||
var c = require("./t1");
|
||||
const c = require("./t1");
|
||||
exports.c = c;
|
||||
c.default;
|
||||
var t1_2 = require("./t1");
|
||||
const t1_2 = require("./t1");
|
||||
exports.d = t1_2.default;
|
||||
t1_2.default;
|
||||
var t1_3 = require("./t1"), e2 = t1_3;
|
||||
const t1_3 = require("./t1"), e2 = t1_3;
|
||||
exports.e1 = t1_3.default;
|
||||
exports.e2 = e2;
|
||||
t1_3.default;
|
||||
e2.default;
|
||||
var t1_4 = require("./t1");
|
||||
const t1_4 = require("./t1");
|
||||
exports.f1 = t1_4.default;
|
||||
exports.f2 = t1_4.default;
|
||||
t1_4.default;
|
||||
|
|
|
@ -20,8 +20,8 @@ use(foo);
|
|||
exports.x = 1;
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
var existingModule_1 = require('./existingModule');
|
||||
var missingModule_1 = require('./missingModule');
|
||||
const existingModule_1 = require('./existingModule');
|
||||
const missingModule_1 = require('./missingModule');
|
||||
const test = { x: existingModule_1.x, foo: missingModule_1.foo };
|
||||
use(existingModule_1.x);
|
||||
use(missingModule_1.foo);
|
||||
|
|
Loading…
Reference in a new issue