|
1 |
| -/a.ts(7,11): error TS6133: '_ns' is declared but its value is never read. |
2 |
| -/a.ts(8,9): error TS6133: '_' is declared but its value is never read. |
| 1 | +unusedLocalsStartingWithUnderscore.ts(2,7): error TS6133: 'unusedVar' is declared but its value is never read. |
| 2 | +unusedLocalsStartingWithUnderscore.ts(3,7): error TS6133: '_unusedVar' is declared but its value is never read. |
| 3 | +unusedLocalsStartingWithUnderscore.ts(5,5): error TS6133: 'unusedLet' is declared but its value is never read. |
| 4 | +unusedLocalsStartingWithUnderscore.ts(6,5): error TS6133: '_unusedLet' is declared but its value is never read. |
| 5 | +unusedLocalsStartingWithUnderscore.ts(8,5): error TS6133: 'unusedVar2' is declared but its value is never read. |
| 6 | +unusedLocalsStartingWithUnderscore.ts(9,5): error TS6133: '_unusedVar2' is declared but its value is never read. |
| 7 | +unusedLocalsStartingWithUnderscore.ts(11,7): error TS6198: All destructured elements are unused. |
| 8 | +unusedLocalsStartingWithUnderscore.ts(12,7): error TS6198: All destructured elements are unused. |
| 9 | +unusedLocalsStartingWithUnderscore.ts(15,10): error TS6133: 'unusedFunc' is declared but its value is never read. |
| 10 | +unusedLocalsStartingWithUnderscore.ts(16,10): error TS6133: '_unusedFunc' is declared but its value is never read. |
| 11 | +unusedLocalsStartingWithUnderscore.ts(18,7): error TS6133: 'unusedArrow' is declared but its value is never read. |
| 12 | +unusedLocalsStartingWithUnderscore.ts(19,7): error TS6133: '_unusedArrow' is declared but its value is never read. |
| 13 | +unusedLocalsStartingWithUnderscore.ts(22,7): error TS6196: 'UnusedClass' is declared but never used. |
| 14 | +unusedLocalsStartingWithUnderscore.ts(23,7): error TS6196: '_UnusedClass' is declared but never used. |
| 15 | +unusedLocalsStartingWithUnderscore.ts(26,11): error TS6196: 'UnusedInterface' is declared but never used. |
| 16 | +unusedLocalsStartingWithUnderscore.ts(27,11): error TS6196: '_UnusedInterface' is declared but never used. |
| 17 | +unusedLocalsStartingWithUnderscore.ts(30,6): error TS6196: 'UnusedType' is declared but never used. |
| 18 | +unusedLocalsStartingWithUnderscore.ts(31,6): error TS6196: '_UnusedType' is declared but never used. |
| 19 | +unusedLocalsStartingWithUnderscore.ts(34,6): error TS6196: 'UnusedEnum' is declared but never used. |
| 20 | +unusedLocalsStartingWithUnderscore.ts(35,6): error TS6196: '_UnusedEnum' is declared but never used. |
| 21 | +unusedLocalsStartingWithUnderscore.ts(39,12): error TS6133: 'x' is declared but its value is never read. |
| 22 | +unusedLocalsStartingWithUnderscore.ts(41,12): error TS6133: 'x' is declared but its value is never read. |
| 23 | +unusedLocalsStartingWithUnderscore.ts(44,11): error TS6133: 'UnusedNamespace' is declared but its value is never read. |
| 24 | +unusedLocalsStartingWithUnderscore.ts(47,11): error TS6133: '_UnusedNamespace' is declared but its value is never read. |
| 25 | +unusedLocalsStartingWithUnderscore.ts(52,7): error TS6133: 'unusedA' is declared but its value is never read. |
| 26 | +unusedLocalsStartingWithUnderscore.ts(54,8): error TS6133: 'unusedC' is declared but its value is never read. |
| 27 | +unusedLocalsStartingWithUnderscore.ts(61,7): error TS6196: 'TestClass' is declared but never used. |
| 28 | +unusedLocalsStartingWithUnderscore.ts(62,13): error TS6133: 'unusedMember' is declared but its value is never read. |
| 29 | +unusedLocalsStartingWithUnderscore.ts(63,13): error TS6133: '_unusedMember' is declared but its value is never read. |
| 30 | +unusedLocalsStartingWithUnderscore.ts(65,13): error TS6133: 'unusedMethod' is declared but its value is never read. |
| 31 | +unusedLocalsStartingWithUnderscore.ts(66,13): error TS6133: '_unusedMethod' is declared but its value is never read. |
| 32 | +unusedLocalsStartingWithUnderscore.ts(69,6): error TS6196: 'TestEnum' is declared but never used. |
| 33 | +unusedLocalsStartingWithUnderscore.ts(74,11): error TS6196: 'TestInterface' is declared but never used. |
| 34 | +unusedLocalsStartingWithUnderscore.ts(79,7): error TS6133: 'obj' is declared but its value is never read. |
3 | 35 |
|
4 | 36 |
|
5 |
| -==== /a.ts (2 errors) ==== |
6 |
| - import * as _ from "./a"; |
| 37 | +==== unusedLocalsStartingWithUnderscore.ts (34 errors) ==== |
| 38 | + // Variables |
| 39 | + const unusedVar = 1; // error |
| 40 | + ~~~~~~~~~ |
| 41 | +!!! error TS6133: 'unusedVar' is declared but its value is never read. |
| 42 | + const _unusedVar = 2; // ok |
| 43 | + ~~~~~~~~~~ |
| 44 | +!!! error TS6133: '_unusedVar' is declared but its value is never read. |
7 | 45 |
|
8 |
| - for (const _ of []) { } |
| 46 | + let unusedLet = 3; // error |
| 47 | + ~~~~~~~~~ |
| 48 | +!!! error TS6133: 'unusedLet' is declared but its value is never read. |
| 49 | + let _unusedLet = 4; // ok |
| 50 | + ~~~~~~~~~~ |
| 51 | +!!! error TS6133: '_unusedLet' is declared but its value is never read. |
9 | 52 |
|
10 |
| - for (const _ in []) { } |
| 53 | + var unusedVar2 = 5; // error |
| 54 | + ~~~~~~~~~~ |
| 55 | +!!! error TS6133: 'unusedVar2' is declared but its value is never read. |
| 56 | + var _unusedVar2 = 6; // ok |
| 57 | + ~~~~~~~~~~~ |
| 58 | +!!! error TS6133: '_unusedVar2' is declared but its value is never read. |
11 | 59 |
|
12 |
| - namespace _ns { |
13 |
| - ~~~ |
14 |
| -!!! error TS6133: '_ns' is declared but its value is never read. |
15 |
| - let _; |
16 |
| - ~ |
17 |
| -!!! error TS6133: '_' is declared but its value is never read. |
18 |
| - for (const _ of []) { } |
| 60 | + const { a1, _b1 } = { a1: 1, _b1: 2 }; // error on a1 |
| 61 | + ~~~~~~~~~~~ |
| 62 | +!!! error TS6198: All destructured elements are unused. |
| 63 | + const { _a2, _b2 } = { _a2: 1, _b2: 2 }; // ok |
| 64 | + ~~~~~~~~~~~~ |
| 65 | +!!! error TS6198: All destructured elements are unused. |
19 | 66 |
|
20 |
| - for (const _ in []) { } |
| 67 | + // Functions |
| 68 | + function unusedFunc() { } // error |
| 69 | + ~~~~~~~~~~ |
| 70 | +!!! error TS6133: 'unusedFunc' is declared but its value is never read. |
| 71 | + function _unusedFunc() { } // ok |
| 72 | + ~~~~~~~~~~~ |
| 73 | +!!! error TS6133: '_unusedFunc' is declared but its value is never read. |
| 74 | + |
| 75 | + const unusedArrow = () => { }; // error |
| 76 | + ~~~~~~~~~~~ |
| 77 | +!!! error TS6133: 'unusedArrow' is declared but its value is never read. |
| 78 | + const _unusedArrow = () => { }; // ok |
| 79 | + ~~~~~~~~~~~~ |
| 80 | +!!! error TS6133: '_unusedArrow' is declared but its value is never read. |
| 81 | + |
| 82 | + // Classes |
| 83 | + class UnusedClass { } // error |
| 84 | + ~~~~~~~~~~~ |
| 85 | +!!! error TS6196: 'UnusedClass' is declared but never used. |
| 86 | + class _UnusedClass { } // ok |
| 87 | + ~~~~~~~~~~~~ |
| 88 | +!!! error TS6196: '_UnusedClass' is declared but never used. |
| 89 | + |
| 90 | + // Interfaces |
| 91 | + interface UnusedInterface { } // error |
| 92 | + ~~~~~~~~~~~~~~~ |
| 93 | +!!! error TS6196: 'UnusedInterface' is declared but never used. |
| 94 | + interface _UnusedInterface { } // ok |
| 95 | + ~~~~~~~~~~~~~~~~ |
| 96 | +!!! error TS6196: '_UnusedInterface' is declared but never used. |
| 97 | + |
| 98 | + // Type aliases |
| 99 | + type UnusedType = string; // error |
| 100 | + ~~~~~~~~~~ |
| 101 | +!!! error TS6196: 'UnusedType' is declared but never used. |
| 102 | + type _UnusedType = string; // ok |
| 103 | + ~~~~~~~~~~~ |
| 104 | +!!! error TS6196: '_UnusedType' is declared but never used. |
| 105 | + |
| 106 | + // Enums |
| 107 | + enum UnusedEnum { A } // error |
| 108 | + ~~~~~~~~~~ |
| 109 | +!!! error TS6196: 'UnusedEnum' is declared but never used. |
| 110 | + enum _UnusedEnum { A } // ok |
| 111 | + ~~~~~~~~~~~ |
| 112 | +!!! error TS6196: '_UnusedEnum' is declared but never used. |
| 113 | + |
| 114 | + // Declarations in for loops |
| 115 | + for (const _x of []) { } // ok |
| 116 | + for (const x of []) { } // error |
| 117 | + ~ |
| 118 | +!!! error TS6133: 'x' is declared but its value is never read. |
| 119 | + for (const _x in []) { } // ok |
| 120 | + for (const x in []) { } // error |
| 121 | + ~ |
| 122 | +!!! error TS6133: 'x' is declared but its value is never read. |
| 123 | + |
| 124 | + // Namespaces |
| 125 | + namespace UnusedNamespace { // error |
| 126 | + ~~~~~~~~~~~~~~~ |
| 127 | +!!! error TS6133: 'UnusedNamespace' is declared but its value is never read. |
| 128 | + export const x = 1; |
| 129 | + } |
| 130 | + namespace _UnusedNamespace { // ok |
| 131 | + ~~~~~~~~~~~~~~~~ |
| 132 | +!!! error TS6133: '_UnusedNamespace' is declared but its value is never read. |
| 133 | + export const x = 1; |
21 | 134 | }
|
22 |
| - |
| 135 | + |
| 136 | + // Destructuring |
| 137 | + const { a: unusedA } = { a: 1 }; // error |
| 138 | + ~~~~~~~~~~~~~~ |
| 139 | +!!! error TS6133: 'unusedA' is declared but its value is never read. |
| 140 | + const { b: _unusedB } = { b: 2 }; // ok |
| 141 | + const [unusedC] = [3]; // error |
| 142 | + ~~~~~~~ |
| 143 | +!!! error TS6133: 'unusedC' is declared but its value is never read. |
| 144 | + const [_unusedD] = [4]; // ok |
| 145 | + |
| 146 | + // |
| 147 | + // The following declarations may _not_ use an underscore to bypass @noUnusedLocals |
| 148 | + // |
| 149 | + |
| 150 | + class TestClass { |
| 151 | + ~~~~~~~~~ |
| 152 | +!!! error TS6196: 'TestClass' is declared but never used. |
| 153 | + private unusedMember = 1; // error |
| 154 | + ~~~~~~~~~~~~ |
| 155 | +!!! error TS6133: 'unusedMember' is declared but its value is never read. |
| 156 | + private _unusedMember = 2; // still error |
| 157 | + ~~~~~~~~~~~~~ |
| 158 | +!!! error TS6133: '_unusedMember' is declared but its value is never read. |
| 159 | + |
| 160 | + private unusedMethod() { } // error |
| 161 | + ~~~~~~~~~~~~ |
| 162 | +!!! error TS6133: 'unusedMethod' is declared but its value is never read. |
| 163 | + private _unusedMethod() { } // still error |
| 164 | + ~~~~~~~~~~~~~ |
| 165 | +!!! error TS6133: '_unusedMethod' is declared but its value is never read. |
| 166 | + } |
| 167 | + |
| 168 | + enum TestEnum { |
| 169 | + ~~~~~~~~ |
| 170 | +!!! error TS6196: 'TestEnum' is declared but never used. |
| 171 | + UnusedMember = 1, // error |
| 172 | + _UnusedMember = 2, // still error |
| 173 | + } |
| 174 | + |
| 175 | + interface TestInterface { |
| 176 | + ~~~~~~~~~~~~~ |
| 177 | +!!! error TS6196: 'TestInterface' is declared but never used. |
| 178 | + unusedProp: number; // error |
| 179 | + _unusedProp: number; // still error |
| 180 | + } |
| 181 | + |
| 182 | + const obj = { |
| 183 | + ~~~ |
| 184 | +!!! error TS6133: 'obj' is declared but its value is never read. |
| 185 | + unusedProp: 1, // error |
| 186 | + _unusedProp: 2, // still error |
| 187 | + }; |
| 188 | + |
| 189 | + export { }; |
0 commit comments