mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 02:15:12 -06:00
Add tests
This commit is contained in:
parent
4789ff0316
commit
62f47fe995
159
tests/baselines/reference/unusedLocalsAndParameters.errors.txt
Normal file
159
tests/baselines/reference/unusedLocalsAndParameters.errors.txt
Normal file
@ -0,0 +1,159 @@
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(5,12): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(10,22): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(16,5): error TS6133: 'farrow' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(16,15): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(19,7): error TS6133: 'C' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(21,12): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(24,11): error TS6133: 'v' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(28,5): error TS6133: 'E' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(30,12): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(33,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(33,11): error TS6133: 'v' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(39,12): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(42,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(42,11): error TS6133: 'v' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(49,10): error TS6133: 'i' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(53,10): error TS6133: 'i' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(57,17): error TS6133: 'n' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(64,11): error TS6133: 'c' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(69,11): error TS6133: 'a' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(72,11): error TS6133: 'c' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(75,11): error TS6133: 'c' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(80,11): error TS6133: 'N' is declared but never used.
|
||||
tests/cases/compiler/unusedLocalsAndParameters.ts(81,9): error TS6133: 'x' is declared but never used.
|
||||
|
||||
|
||||
==== tests/cases/compiler/unusedLocalsAndParameters.ts (24 errors) ====
|
||||
|
||||
export { };
|
||||
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
}
|
||||
f(0);
|
||||
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
};
|
||||
|
||||
fexp(0);
|
||||
|
||||
// arrow function paramter
|
||||
var farrow = (a) => {
|
||||
~~~~~~
|
||||
!!! error TS6133: 'farrow' is declared but never used.
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
};
|
||||
|
||||
class C {
|
||||
~
|
||||
!!! error TS6133: 'C' is declared but never used.
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~
|
||||
!!! error TS6133: 'v' is declared but never used.
|
||||
}
|
||||
}
|
||||
|
||||
var E = class {
|
||||
~
|
||||
!!! error TS6133: 'E' is declared but never used.
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~
|
||||
!!! error TS6133: 'v' is declared but never used.
|
||||
}
|
||||
}
|
||||
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method(a) {
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~
|
||||
!!! error TS6133: 'v' is declared but never used.
|
||||
}
|
||||
};
|
||||
|
||||
o;
|
||||
|
||||
// in a for..in statment
|
||||
for (let i in o) {
|
||||
~
|
||||
!!! error TS6133: 'i' is declared but never used.
|
||||
}
|
||||
|
||||
// in a for..of statment
|
||||
for (let i of [1, 2, 3]) {
|
||||
~
|
||||
!!! error TS6133: 'i' is declared but never used.
|
||||
}
|
||||
|
||||
// in a for. statment
|
||||
for (let i = 0, n; i < 10; i++) {
|
||||
~
|
||||
!!! error TS6133: 'n' is declared but never used.
|
||||
}
|
||||
|
||||
// in a block
|
||||
|
||||
const condition = false;
|
||||
if (condition) {
|
||||
const c = 0;
|
||||
~
|
||||
!!! error TS6133: 'c' is declared but never used.
|
||||
}
|
||||
|
||||
// in try/catch/finally
|
||||
try {
|
||||
const a = 0;
|
||||
~
|
||||
!!! error TS6133: 'a' is declared but never used.
|
||||
}
|
||||
catch (e) {
|
||||
const c = 1;
|
||||
~
|
||||
!!! error TS6133: 'c' is declared but never used.
|
||||
}
|
||||
finally {
|
||||
const c = 0;
|
||||
~
|
||||
!!! error TS6133: 'c' is declared but never used.
|
||||
}
|
||||
|
||||
|
||||
// in a namespace
|
||||
namespace N {
|
||||
~
|
||||
!!! error TS6133: 'N' is declared but never used.
|
||||
var x;
|
||||
~
|
||||
!!! error TS6133: 'x' is declared but never used.
|
||||
}
|
||||
|
||||
|
||||
168
tests/baselines/reference/unusedLocalsAndParameters.js
Normal file
168
tests/baselines/reference/unusedLocalsAndParameters.js
Normal file
@ -0,0 +1,168 @@
|
||||
//// [unusedLocalsAndParameters.ts]
|
||||
|
||||
export { };
|
||||
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
}
|
||||
f(0);
|
||||
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
};
|
||||
|
||||
fexp(0);
|
||||
|
||||
// arrow function paramter
|
||||
var farrow = (a) => {
|
||||
};
|
||||
|
||||
class C {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
}
|
||||
}
|
||||
|
||||
var E = class {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
}
|
||||
}
|
||||
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method(a) {
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
}
|
||||
};
|
||||
|
||||
o;
|
||||
|
||||
// in a for..in statment
|
||||
for (let i in o) {
|
||||
}
|
||||
|
||||
// in a for..of statment
|
||||
for (let i of [1, 2, 3]) {
|
||||
}
|
||||
|
||||
// in a for. statment
|
||||
for (let i = 0, n; i < 10; i++) {
|
||||
}
|
||||
|
||||
// in a block
|
||||
|
||||
const condition = false;
|
||||
if (condition) {
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
// in try/catch/finally
|
||||
try {
|
||||
const a = 0;
|
||||
}
|
||||
catch (e) {
|
||||
const c = 1;
|
||||
}
|
||||
finally {
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
|
||||
// in a namespace
|
||||
namespace N {
|
||||
var x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [unusedLocalsAndParameters.js]
|
||||
"use strict";
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
}
|
||||
f(0);
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
};
|
||||
fexp(0);
|
||||
// arrow function paramter
|
||||
var farrow = function (a) {
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
// Method declaration paramter
|
||||
C.prototype.method = function (a) {
|
||||
};
|
||||
Object.defineProperty(C.prototype, "x", {
|
||||
// Accessor declaration paramter
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
}());
|
||||
var E = (function () {
|
||||
function class_1() {
|
||||
}
|
||||
// Method declaration paramter
|
||||
class_1.prototype.method = function (a) {
|
||||
};
|
||||
Object.defineProperty(class_1.prototype, "x", {
|
||||
// Accessor declaration paramter
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return class_1;
|
||||
}());
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method: function (a) {
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v) {
|
||||
}
|
||||
};
|
||||
o;
|
||||
// in a for..in statment
|
||||
for (var i in o) {
|
||||
}
|
||||
// in a for..of statment
|
||||
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {
|
||||
var i = _a[_i];
|
||||
}
|
||||
// in a for. statment
|
||||
for (var i = 0, n = void 0; i < 10; i++) {
|
||||
}
|
||||
// in a block
|
||||
var condition = false;
|
||||
if (condition) {
|
||||
var c = 0;
|
||||
}
|
||||
// in try/catch/finally
|
||||
try {
|
||||
var a = 0;
|
||||
}
|
||||
catch (e) {
|
||||
var c = 1;
|
||||
}
|
||||
finally {
|
||||
var c = 0;
|
||||
}
|
||||
// in a namespace
|
||||
var N;
|
||||
(function (N) {
|
||||
var x;
|
||||
})(N || (N = {}));
|
||||
@ -0,0 +1,172 @@
|
||||
tests/cases/compiler/unusedLocalsAndParametersDeferred.ts(42,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/unusedLocalsAndParametersDeferred.ts(65,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/unusedLocalsAndParametersDeferred.ts(87,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
==== tests/cases/compiler/unusedLocalsAndParametersDeferred.ts (3 errors) ====
|
||||
|
||||
export { };
|
||||
|
||||
function defered<T>(a: () => T): T {
|
||||
return a();
|
||||
}
|
||||
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
f(0);
|
||||
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
};
|
||||
fexp(1);
|
||||
|
||||
// arrow function paramter
|
||||
var farrow = (a) => {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
};
|
||||
farrow(2);
|
||||
|
||||
let prop1;
|
||||
|
||||
class C {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
}
|
||||
// in a property initalizer
|
||||
p = defered(() => {
|
||||
prop1;
|
||||
});
|
||||
}
|
||||
|
||||
new C();
|
||||
|
||||
let prop2;
|
||||
|
||||
var E = class {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
}
|
||||
// in a property initalizer
|
||||
p = defered(() => {
|
||||
prop2;
|
||||
});
|
||||
}
|
||||
|
||||
new E();
|
||||
|
||||
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
},
|
||||
// in a property initalizer
|
||||
p: defered(() => {
|
||||
prop1;
|
||||
})
|
||||
};
|
||||
|
||||
o;
|
||||
|
||||
// in a for..in statment
|
||||
for (let i in o) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a for..of statment
|
||||
for (let i of [1,2,3]) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a for. statment
|
||||
for (let i = 0; i < 10; i++) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a block
|
||||
|
||||
const condition = false;
|
||||
if (condition) {
|
||||
const c = 0;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
|
||||
// in try/catch/finally
|
||||
try {
|
||||
const a = 0;
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
const c = 1;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
finally {
|
||||
const c = 0;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// in a namespace
|
||||
namespace N {
|
||||
var x;
|
||||
defered(() => {
|
||||
x;
|
||||
});
|
||||
}
|
||||
N;
|
||||
|
||||
325
tests/baselines/reference/unusedLocalsAndParametersDeferred.js
Normal file
325
tests/baselines/reference/unusedLocalsAndParametersDeferred.js
Normal file
@ -0,0 +1,325 @@
|
||||
//// [unusedLocalsAndParametersDeferred.ts]
|
||||
|
||||
export { };
|
||||
|
||||
function defered<T>(a: () => T): T {
|
||||
return a();
|
||||
}
|
||||
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
f(0);
|
||||
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
};
|
||||
fexp(1);
|
||||
|
||||
// arrow function paramter
|
||||
var farrow = (a) => {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
};
|
||||
farrow(2);
|
||||
|
||||
let prop1;
|
||||
|
||||
class C {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
}
|
||||
// in a property initalizer
|
||||
p = defered(() => {
|
||||
prop1;
|
||||
});
|
||||
}
|
||||
|
||||
new C();
|
||||
|
||||
let prop2;
|
||||
|
||||
var E = class {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
}
|
||||
// in a property initalizer
|
||||
p = defered(() => {
|
||||
prop2;
|
||||
});
|
||||
}
|
||||
|
||||
new E();
|
||||
|
||||
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
},
|
||||
// in a property initalizer
|
||||
p: defered(() => {
|
||||
prop1;
|
||||
})
|
||||
};
|
||||
|
||||
o;
|
||||
|
||||
// in a for..in statment
|
||||
for (let i in o) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a for..of statment
|
||||
for (let i of [1,2,3]) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a for. statment
|
||||
for (let i = 0; i < 10; i++) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a block
|
||||
|
||||
const condition = false;
|
||||
if (condition) {
|
||||
const c = 0;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
|
||||
// in try/catch/finally
|
||||
try {
|
||||
const a = 0;
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
const c = 1;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
finally {
|
||||
const c = 0;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// in a namespace
|
||||
namespace N {
|
||||
var x;
|
||||
defered(() => {
|
||||
x;
|
||||
});
|
||||
}
|
||||
N;
|
||||
|
||||
|
||||
//// [unusedLocalsAndParametersDeferred.js]
|
||||
"use strict";
|
||||
function defered(a) {
|
||||
return a();
|
||||
}
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
defered(function () {
|
||||
a;
|
||||
});
|
||||
}
|
||||
f(0);
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
defered(function () {
|
||||
a;
|
||||
});
|
||||
};
|
||||
fexp(1);
|
||||
// arrow function paramter
|
||||
var farrow = function (a) {
|
||||
defered(function () {
|
||||
a;
|
||||
});
|
||||
};
|
||||
farrow(2);
|
||||
var prop1;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
// in a property initalizer
|
||||
this.p = defered(function () {
|
||||
prop1;
|
||||
});
|
||||
}
|
||||
// Method declaration paramter
|
||||
C.prototype.method = function (a) {
|
||||
defered(function () {
|
||||
a;
|
||||
});
|
||||
};
|
||||
Object.defineProperty(C.prototype, "x", {
|
||||
// Accessor declaration paramter
|
||||
set: function (v) {
|
||||
defered(function () {
|
||||
v;
|
||||
});
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
}());
|
||||
new C();
|
||||
var prop2;
|
||||
var E = (function () {
|
||||
function class_1() {
|
||||
// in a property initalizer
|
||||
this.p = defered(function () {
|
||||
prop2;
|
||||
});
|
||||
}
|
||||
// Method declaration paramter
|
||||
class_1.prototype.method = function (a) {
|
||||
defered(function () {
|
||||
a;
|
||||
});
|
||||
};
|
||||
Object.defineProperty(class_1.prototype, "x", {
|
||||
// Accessor declaration paramter
|
||||
set: function (v) {
|
||||
defered(function () {
|
||||
v;
|
||||
});
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return class_1;
|
||||
}());
|
||||
new E();
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method: function (a) {
|
||||
defered(function () {
|
||||
a;
|
||||
});
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v) {
|
||||
defered(function () {
|
||||
v;
|
||||
});
|
||||
},
|
||||
// in a property initalizer
|
||||
p: defered(function () {
|
||||
prop1;
|
||||
})
|
||||
};
|
||||
o;
|
||||
// in a for..in statment
|
||||
var _loop_1 = function(i) {
|
||||
defered(function () {
|
||||
i;
|
||||
});
|
||||
};
|
||||
for (var i in o) {
|
||||
_loop_1(i);
|
||||
}
|
||||
// in a for..of statment
|
||||
var _loop_2 = function(i) {
|
||||
defered(function () {
|
||||
i;
|
||||
});
|
||||
};
|
||||
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {
|
||||
var i = _a[_i];
|
||||
_loop_2(i);
|
||||
}
|
||||
// in a for. statment
|
||||
var _loop_3 = function(i) {
|
||||
defered(function () {
|
||||
i;
|
||||
});
|
||||
};
|
||||
for (var i = 0; i < 10; i++) {
|
||||
_loop_3(i);
|
||||
}
|
||||
// in a block
|
||||
var condition = false;
|
||||
if (condition) {
|
||||
var c_1 = 0;
|
||||
defered(function () {
|
||||
c_1;
|
||||
});
|
||||
}
|
||||
// in try/catch/finally
|
||||
try {
|
||||
var a_1 = 0;
|
||||
defered(function () {
|
||||
a_1;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
var c_2 = 1;
|
||||
defered(function () {
|
||||
c_2;
|
||||
});
|
||||
}
|
||||
finally {
|
||||
var c_3 = 0;
|
||||
defered(function () {
|
||||
c_3;
|
||||
});
|
||||
}
|
||||
// in a namespace
|
||||
var N;
|
||||
(function (N) {
|
||||
var x;
|
||||
defered(function () {
|
||||
x;
|
||||
});
|
||||
})(N || (N = {}));
|
||||
N;
|
||||
@ -0,0 +1,45 @@
|
||||
//// [unusedLocalsAndParametersOverloadSignatures.ts]
|
||||
|
||||
export function func(details: number, message: string, ...args: any[]): void;
|
||||
export function func(details: number, message: string): any {
|
||||
return details + message;
|
||||
}
|
||||
|
||||
export class C {
|
||||
constructor(details: number, message: string, ...args: any[]);
|
||||
constructor(details: number, message: string) {
|
||||
details + message;
|
||||
}
|
||||
|
||||
method(details: number, message: string, ...args: any[]): void;
|
||||
method(details: number, message: string): any {
|
||||
return details + message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function genericFunc<T>(details: number, message: T, ...args: any[]): void;
|
||||
export function genericFunc(details: number, message: any): any {
|
||||
return details + message;
|
||||
}
|
||||
|
||||
//// [unusedLocalsAndParametersOverloadSignatures.js]
|
||||
"use strict";
|
||||
function func(details, message) {
|
||||
return details + message;
|
||||
}
|
||||
exports.func = func;
|
||||
var C = (function () {
|
||||
function C(details, message) {
|
||||
details + message;
|
||||
}
|
||||
C.prototype.method = function (details, message) {
|
||||
return details + message;
|
||||
};
|
||||
return C;
|
||||
}());
|
||||
exports.C = C;
|
||||
function genericFunc(details, message) {
|
||||
return details + message;
|
||||
}
|
||||
exports.genericFunc = genericFunc;
|
||||
@ -0,0 +1,70 @@
|
||||
=== tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts ===
|
||||
|
||||
export function func(details: number, message: string, ...args: any[]): void;
|
||||
>func : Symbol(func, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 0, 0), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 77))
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 21))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 37))
|
||||
>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 54))
|
||||
|
||||
export function func(details: number, message: string): any {
|
||||
>func : Symbol(func, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 0, 0), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 1, 77))
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 21))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 37))
|
||||
|
||||
return details + message;
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 21))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 2, 37))
|
||||
}
|
||||
|
||||
export class C {
|
||||
>C : Symbol(C, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 4, 1))
|
||||
|
||||
constructor(details: number, message: string, ...args: any[]);
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 7, 16))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 7, 32))
|
||||
>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 7, 49))
|
||||
|
||||
constructor(details: number, message: string) {
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 16))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 32))
|
||||
|
||||
details + message;
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 16))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 8, 32))
|
||||
}
|
||||
|
||||
method(details: number, message: string, ...args: any[]): void;
|
||||
>method : Symbol(C.method, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 10, 5), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 67))
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 11))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 27))
|
||||
>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 44))
|
||||
|
||||
method(details: number, message: string): any {
|
||||
>method : Symbol(C.method, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 10, 5), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 12, 67))
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 11))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 27))
|
||||
|
||||
return details + message;
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 11))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 13, 27))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function genericFunc<T>(details: number, message: T, ...args: any[]): void;
|
||||
>genericFunc : Symbol(genericFunc, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 16, 1), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 82))
|
||||
>T : Symbol(T, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 28))
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 31))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 47))
|
||||
>T : Symbol(T, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 28))
|
||||
>args : Symbol(args, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 59))
|
||||
|
||||
export function genericFunc(details: number, message: any): any {
|
||||
>genericFunc : Symbol(genericFunc, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 16, 1), Decl(unusedLocalsAndParametersOverloadSignatures.ts, 19, 82))
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 28))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 44))
|
||||
|
||||
return details + message;
|
||||
>details : Symbol(details, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 28))
|
||||
>message : Symbol(message, Decl(unusedLocalsAndParametersOverloadSignatures.ts, 20, 44))
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
=== tests/cases/compiler/unusedLocalsAndParametersOverloadSignatures.ts ===
|
||||
|
||||
export function func(details: number, message: string, ...args: any[]): void;
|
||||
>func : (details: number, message: string, ...args: any[]) => void
|
||||
>details : number
|
||||
>message : string
|
||||
>args : any[]
|
||||
|
||||
export function func(details: number, message: string): any {
|
||||
>func : (details: number, message: string, ...args: any[]) => void
|
||||
>details : number
|
||||
>message : string
|
||||
|
||||
return details + message;
|
||||
>details + message : string
|
||||
>details : number
|
||||
>message : string
|
||||
}
|
||||
|
||||
export class C {
|
||||
>C : C
|
||||
|
||||
constructor(details: number, message: string, ...args: any[]);
|
||||
>details : number
|
||||
>message : string
|
||||
>args : any[]
|
||||
|
||||
constructor(details: number, message: string) {
|
||||
>details : number
|
||||
>message : string
|
||||
|
||||
details + message;
|
||||
>details + message : string
|
||||
>details : number
|
||||
>message : string
|
||||
}
|
||||
|
||||
method(details: number, message: string, ...args: any[]): void;
|
||||
>method : (details: number, message: string, ...args: any[]) => void
|
||||
>details : number
|
||||
>message : string
|
||||
>args : any[]
|
||||
|
||||
method(details: number, message: string): any {
|
||||
>method : (details: number, message: string, ...args: any[]) => void
|
||||
>details : number
|
||||
>message : string
|
||||
|
||||
return details + message;
|
||||
>details + message : string
|
||||
>details : number
|
||||
>message : string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function genericFunc<T>(details: number, message: T, ...args: any[]): void;
|
||||
>genericFunc : <T>(details: number, message: T, ...args: any[]) => void
|
||||
>T : T
|
||||
>details : number
|
||||
>message : T
|
||||
>T : T
|
||||
>args : any[]
|
||||
|
||||
export function genericFunc(details: number, message: any): any {
|
||||
>genericFunc : <T>(details: number, message: T, ...args: any[]) => void
|
||||
>details : number
|
||||
>message : any
|
||||
|
||||
return details + message;
|
||||
>details + message : any
|
||||
>details : number
|
||||
>message : any
|
||||
}
|
||||
86
tests/cases/compiler/unusedLocalsAndParameters.ts
Normal file
86
tests/cases/compiler/unusedLocalsAndParameters.ts
Normal file
@ -0,0 +1,86 @@
|
||||
//@noUnusedLocals:true
|
||||
//@noUnusedParameters:true
|
||||
|
||||
export { };
|
||||
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
}
|
||||
f(0);
|
||||
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
};
|
||||
|
||||
fexp(0);
|
||||
|
||||
// arrow function paramter
|
||||
var farrow = (a) => {
|
||||
};
|
||||
|
||||
class C {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
}
|
||||
}
|
||||
|
||||
var E = class {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
}
|
||||
}
|
||||
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method(a) {
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
}
|
||||
};
|
||||
|
||||
o;
|
||||
|
||||
// in a for..in statment
|
||||
for (let i in o) {
|
||||
}
|
||||
|
||||
// in a for..of statment
|
||||
for (let i of [1, 2, 3]) {
|
||||
}
|
||||
|
||||
// in a for. statment
|
||||
for (let i = 0, n; i < 10; i++) {
|
||||
}
|
||||
|
||||
// in a block
|
||||
|
||||
const condition = false;
|
||||
if (condition) {
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
// in try/catch/finally
|
||||
try {
|
||||
const a = 0;
|
||||
}
|
||||
catch (e) {
|
||||
const c = 1;
|
||||
}
|
||||
finally {
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
|
||||
// in a namespace
|
||||
namespace N {
|
||||
var x;
|
||||
}
|
||||
|
||||
|
||||
162
tests/cases/compiler/unusedLocalsAndParametersDeferred.ts
Normal file
162
tests/cases/compiler/unusedLocalsAndParametersDeferred.ts
Normal file
@ -0,0 +1,162 @@
|
||||
//@noUnusedLocals:true
|
||||
//@noUnusedParameters:true
|
||||
|
||||
export { };
|
||||
|
||||
function defered<T>(a: () => T): T {
|
||||
return a();
|
||||
}
|
||||
|
||||
// function declaration paramter
|
||||
function f(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
f(0);
|
||||
|
||||
// function expression paramter
|
||||
var fexp = function (a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
};
|
||||
fexp(1);
|
||||
|
||||
// arrow function paramter
|
||||
var farrow = (a) => {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
};
|
||||
farrow(2);
|
||||
|
||||
let prop1;
|
||||
|
||||
class C {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
}
|
||||
// in a property initalizer
|
||||
p = defered(() => {
|
||||
prop1;
|
||||
});
|
||||
}
|
||||
|
||||
new C();
|
||||
|
||||
let prop2;
|
||||
|
||||
var E = class {
|
||||
// Method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
}
|
||||
// in a property initalizer
|
||||
p = defered(() => {
|
||||
prop2;
|
||||
});
|
||||
}
|
||||
|
||||
new E();
|
||||
|
||||
|
||||
var o = {
|
||||
// Object literal method declaration paramter
|
||||
method(a) {
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
},
|
||||
// Accessor declaration paramter
|
||||
set x(v: number) {
|
||||
defered(() => {
|
||||
v;
|
||||
});
|
||||
},
|
||||
// in a property initalizer
|
||||
p: defered(() => {
|
||||
prop1;
|
||||
})
|
||||
};
|
||||
|
||||
o;
|
||||
|
||||
// in a for..in statment
|
||||
for (let i in o) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a for..of statment
|
||||
for (let i of [1,2,3]) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a for. statment
|
||||
for (let i = 0; i < 10; i++) {
|
||||
defered(() => {
|
||||
i;
|
||||
});
|
||||
}
|
||||
|
||||
// in a block
|
||||
|
||||
const condition = false;
|
||||
if (condition) {
|
||||
const c = 0;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
|
||||
// in try/catch/finally
|
||||
try {
|
||||
const a = 0;
|
||||
defered(() => {
|
||||
a;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
const c = 1;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
finally {
|
||||
const c = 0;
|
||||
defered(() => {
|
||||
c;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// in a namespace
|
||||
namespace N {
|
||||
var x;
|
||||
defered(() => {
|
||||
x;
|
||||
});
|
||||
}
|
||||
N;
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
//@noUnusedLocals:true
|
||||
//@noUnusedParameters:true
|
||||
|
||||
export function func(details: number, message: string, ...args: any[]): void;
|
||||
export function func(details: number, message: string): any {
|
||||
return details + message;
|
||||
}
|
||||
|
||||
export class C {
|
||||
constructor(details: number, message: string, ...args: any[]);
|
||||
constructor(details: number, message: string) {
|
||||
details + message;
|
||||
}
|
||||
|
||||
method(details: number, message: string, ...args: any[]): void;
|
||||
method(details: number, message: string): any {
|
||||
return details + message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function genericFunc<T>(details: number, message: T, ...args: any[]): void;
|
||||
export function genericFunc(details: number, message: any): any {
|
||||
return details + message;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user