Files
tsgo/testdata/baselines/reference/submodule/compiler/duplicateVariablesByScope.js

66 lines
1.0 KiB
TypeScript

//// [tests/cases/compiler/duplicateVariablesByScope.ts] ////
//// [duplicateVariablesByScope.ts]
// duplicate local variables are only reported at global scope
namespace M {
for (var j = 0; j < 10; j++) {
}
for (var j = 0; j < 10; j++) {
}
}
function foo() {
var x = 2;
var x = 1;
if (true) {
var result = 1;
}
else {
var result = 2;
}
}
class C {
foo() {
try {
var x = 1;
}
catch (e) {
var x = 2;
}
}
}
//// [duplicateVariablesByScope.js]
"use strict";
// duplicate local variables are only reported at global scope
var M;
(function (M) {
for (var j = 0; j < 10; j++) {
}
for (var j = 0; j < 10; j++) {
}
})(M || (M = {}));
function foo() {
var x = 2;
var x = 1;
if (true) {
var result = 1;
}
else {
var result = 2;
}
}
class C {
foo() {
try {
var x = 1;
}
catch (e) {
var x = 2;
}
}
}