Skip to content

Commit 4eb84da

Browse files
committedAug 15, 2023
Fix VSCode reported lint issues (#4153, #4156, #4158, #4159).
1 parent 609e2f5 commit 4eb84da

15 files changed

+26
-25
lines changed
 

Diff for: ‎src.ts/_admin/test-browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ const TestData = (function() {
201201
return [ String(data.length), zlib.deflateRawSync(data).toString("base64") ].join(",");
202202
}
203203

204-
let data = [ ];
204+
let data: Array<string> = [ ];
205205
data.push(`import { ethers } from "/index.js";`);
206206
data.push(`import { inflate } from "/static/tiny-inflate.js";`);
207207
data.push(`const fs = new Map();`);

Diff for: ‎src.ts/_tests/test-contract.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ describe("Test Typed Contract Interaction", function() {
249249
}
250250
];
251251

252-
const abi = [ ];
252+
const abi: Array<string> = [ ];
253253
for (let i = 1; i <= 32; i++) {
254254
abi.push(`function testTyped(uint${ i * 8 }) public pure returns (string memory)`);
255255
abi.push(`function testTyped(int${ i * 8 }) public pure returns (string memory)`);

Diff for: ‎src.ts/_tests/test-wallet-mnemonic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function fromHex(hex: string): string {
1818
}
1919

2020
function repeat(text: string, length: number): Array<string> {
21-
const result = [ ];
21+
const result: Array<string> = [ ];
2222
while (result.length < length) { result.push(text); }
2323
return result;
2424
}

Diff for: ‎src.ts/abi/coders/abstract-coder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class Result extends Array<any> {
182182
}
183183
if (end > this.length) { end = this.length; }
184184

185-
const result = [ ], names = [ ];
185+
const result: Array<any> = [ ], names: Array<null | string> = [ ];
186186
for (let i = start; i < end; i++) {
187187
result.push(this[i]);
188188
names.push(this.#names[i]);
@@ -195,7 +195,7 @@ export class Result extends Array<any> {
195195
* @_ignore
196196
*/
197197
filter(callback: (el: any, index: number, array: Result) => boolean, thisArg?: any): Result {
198-
const result = [ ], names = [ ];
198+
const result: Array<any> = [ ], names: Array<null | string> = [ ];
199199
for (let i = 0; i < this.length; i++) {
200200
const item = this[i];
201201
if (item instanceof Error) {

Diff for: ‎src.ts/abi/coders/array.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class ArrayCoder extends Coder {
171171

172172
assertArgumentCount(value.length, count, "coder array" + (this.localName? (" "+ this.localName): ""));
173173

174-
let coders = [];
174+
let coders: Array<Coder> = [ ];
175175
for (let i = 0; i < value.length; i++) { coders.push(this.coder); }
176176

177177
return pack(writer, coders, value);
@@ -190,7 +190,7 @@ export class ArrayCoder extends Coder {
190190
assert(count * WordSize <= reader.dataLength, "insufficient data length",
191191
"BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * WordSize, length: reader.dataLength });
192192
}
193-
let coders = [];
193+
let coders: Array<Coder> = [];
194194
for (let i = 0; i < count; i++) { coders.push(new AnonymousCoder(this.coder)); }
195195

196196
return unpack(reader, coders);

Diff for: ‎src.ts/abi/fragments.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ export class ParamType {
843843
comps = null;
844844
}
845845

846-
let indexed = null;
846+
let indexed: null | boolean = null;
847847
const keywords = consumeKeywords(obj, KwModifiers);
848848
if (keywords.has("indexed")) {
849849
if (!allowIndexed) { throw new Error(""); }
@@ -1079,7 +1079,7 @@ export class ErrorFragment extends NamedFragment {
10791079
});
10801080
}
10811081

1082-
const result = [ ];
1082+
const result: Array<string> = [ ];
10831083
if (format !== "sighash") { result.push("error"); }
10841084
result.push(this.name + joinParams(format, this.inputs));
10851085
return result.join(" ");
@@ -1154,7 +1154,7 @@ export class EventFragment extends NamedFragment {
11541154
});
11551155
}
11561156

1157-
const result = [ ];
1157+
const result: Array<string> = [ ];
11581158
if (format !== "sighash") { result.push("event"); }
11591159
result.push(this.name + joinParams(format, this.inputs));
11601160
if (format !== "sighash" && this.anonymous) { result.push("anonymous"); }
@@ -1465,7 +1465,7 @@ export class FunctionFragment extends NamedFragment {
14651465
});
14661466
}
14671467

1468-
const result = [];
1468+
const result: Array<string> = [];
14691469

14701470
if (format !== "sighash") { result.push("function"); }
14711471

Diff for: ‎src.ts/abi/interface.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ export class Interface {
595595

596596
// It is a bare name, look up the function (will return null if ambiguous)
597597
if (key.indexOf("(") === -1) {
598-
const matching = [ ];
598+
const matching: Array<EventFragment> = [ ];
599599
for (const [ name, fragment ] of this.#events) {
600600
if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); }
601601
}
@@ -716,7 +716,7 @@ export class Interface {
716716

717717
// It is a bare name, look up the function (will return null if ambiguous)
718718
if (key.indexOf("(") === -1) {
719-
const matching = [ ];
719+
const matching: Array<ErrorFragment> = [ ];
720720
for (const [ name, fragment ] of this.#errors) {
721721
if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); }
722722
}
@@ -1154,7 +1154,7 @@ export class Interface {
11541154
const keys: Array<null | string> = [ ];
11551155
let nonIndexedIndex = 0, indexedIndex = 0;
11561156
fragment.inputs.forEach((param, index) => {
1157-
let value = null;
1157+
let value: null | Indexed = null;
11581158
if (param.indexed) {
11591159
if (resultIndexed == null) {
11601160
value = new Indexed(null);

Diff for: ‎src.ts/contract/contract.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ export class BaseContract implements Addressable, EventEmitterable<ContractEvent
679679
Object.defineProperty(this, internal, { value: { } });
680680

681681
let addrPromise;
682-
let addr = null;
682+
let addr: null | string = null;
683683

684684
let deployTx: null | ContractTransactionResponse = null;
685685
if (_deployTx) {

Diff for: ‎src.ts/providers/abstract-provider.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,8 @@ export class AbstractProvider implements Provider {
907907
})())
908908
});
909909

910-
let maxFeePerGas = null, maxPriorityFeePerGas = null;
910+
let maxFeePerGas: null | bigint = null;
911+
let maxPriorityFeePerGas: null | bigint = null;
911912

912913
// These are the recommended EIP-1559 heuristics for fee data
913914
const block = this._wrapBlock(_block, network);

Diff for: ‎src.ts/providers/provider-fallback.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ function getFuzzyMode(quorum: number, results: Array<TallyResult>): undefined |
332332
}
333333

334334
let bestWeight = 0;
335-
let bestResult = undefined;
335+
let bestResult: undefined | number = undefined;
336336

337337
for (const { weight, result } of tally.values()) {
338338
// Use this result, if this result meets quorum and has either:

Diff for: ‎src.ts/utils/rlp-decode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Decoded = {
2727
};
2828

2929
function _decodeChildren(data: Uint8Array, offset: number, childOffset: number, length: number): Decoded {
30-
const result = [];
30+
const result: Array<any> = [];
3131

3232
while (childOffset < offset + 1 + length) {
3333
const decoded = _decode(data, childOffset);

Diff for: ‎src.ts/utils/rlp-encode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { RlpStructuredData } from "./rlp.js";
66

77

88
function arrayifyInteger(value: number): Array<number> {
9-
const result = [];
9+
const result: Array<number> = [];
1010
while (value) {
1111
result.unshift(value & 0xff);
1212
value >>= 8;

Diff for: ‎src.ts/utils/utf8.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ function getUtf8CodePoints(_bytes: BytesLike, onError?: Utf8ErrorFunc): Array<nu
162162
}
163163

164164
// Multibyte; how many bytes left for this character?
165-
let extraLength = null;
166-
let overlongMask = null;
165+
let extraLength: null | number = null;
166+
let overlongMask: null | number = null;
167167

168168
// 110x xxxx 10xx xxxx
169169
if ((c & 0xe0) === 0xc0) {
@@ -253,7 +253,7 @@ export function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8
253253
str = str.normalize(form);
254254
}
255255

256-
let result = [];
256+
let result: Array<number> = [];
257257
for (let i = 0; i < str.length; i++) {
258258
const c = str.charCodeAt(i);
259259

Diff for: ‎src.ts/wordlists/lang-ja.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function toString(data: Array<number>): string {
4949
function loadWords(): Array<string> {
5050
if (_wordlist !== null) { return _wordlist; }
5151

52-
const wordlist = [];
52+
const wordlist: Array<string> = [];
5353

5454
// Transforms for normalizing (sort is a not quite UTF-8)
5555
const transform: { [key: string]: string | boolean } = {};
@@ -91,7 +91,7 @@ function loadWords(): Array<string> {
9191
for (let length = 3; length <= 9; length++) {
9292
const d = data[length - 3];
9393
for (let offset = 0; offset < d.length; offset += length) {
94-
const word = [];
94+
const word: Array<number> = [];
9595
for (let i = 0; i < length; i++) {
9696
const k = mapping.indexOf(d[offset + i]);
9797
word.push(227);

Diff for: ‎src.ts/wordlists/lang-zh.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const style = "~!@#$%^&*_-=[]{}|;:,.()<>?"
2424
function loadWords(locale: string): Array<string> {
2525
if (_wordlist[locale] != null) { return _wordlist[locale] as Array<string>; }
2626

27-
const wordlist = [];
27+
const wordlist: Array<string> = [];
2828

2929
let deltaOffset = 0;
3030
for (let i = 0; i < 2048; i++) {

0 commit comments

Comments
 (0)
Please sign in to comment.