Fix VSCode reported lint issues (#4153, #4156, #4158, #4159).

This commit is contained in:
Richard Moore 2023-08-14 20:00:45 -04:00
parent 609e2f53eb
commit 4eb84da865
15 changed files with 26 additions and 25 deletions

@ -201,7 +201,7 @@ const TestData = (function() {
return [ String(data.length), zlib.deflateRawSync(data).toString("base64") ].join(",");
}
let data = [ ];
let data: Array<string> = [ ];
data.push(`import { ethers } from "/index.js";`);
data.push(`import { inflate } from "/static/tiny-inflate.js";`);
data.push(`const fs = new Map();`);

@ -249,7 +249,7 @@ describe("Test Typed Contract Interaction", function() {
}
];
const abi = [ ];
const abi: Array<string> = [ ];
for (let i = 1; i <= 32; i++) {
abi.push(`function testTyped(uint${ i * 8 }) public pure returns (string memory)`);
abi.push(`function testTyped(int${ i * 8 }) public pure returns (string memory)`);

@ -18,7 +18,7 @@ function fromHex(hex: string): string {
}
function repeat(text: string, length: number): Array<string> {
const result = [ ];
const result: Array<string> = [ ];
while (result.length < length) { result.push(text); }
return result;
}

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

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

@ -843,7 +843,7 @@ export class ParamType {
comps = null;
}
let indexed = null;
let indexed: null | boolean = null;
const keywords = consumeKeywords(obj, KwModifiers);
if (keywords.has("indexed")) {
if (!allowIndexed) { throw new Error(""); }
@ -1079,7 +1079,7 @@ export class ErrorFragment extends NamedFragment {
});
}
const result = [ ];
const result: Array<string> = [ ];
if (format !== "sighash") { result.push("error"); }
result.push(this.name + joinParams(format, this.inputs));
return result.join(" ");
@ -1154,7 +1154,7 @@ export class EventFragment extends NamedFragment {
});
}
const result = [ ];
const result: Array<string> = [ ];
if (format !== "sighash") { result.push("event"); }
result.push(this.name + joinParams(format, this.inputs));
if (format !== "sighash" && this.anonymous) { result.push("anonymous"); }
@ -1465,7 +1465,7 @@ export class FunctionFragment extends NamedFragment {
});
}
const result = [];
const result: Array<string> = [];
if (format !== "sighash") { result.push("function"); }

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

@ -679,7 +679,7 @@ export class BaseContract implements Addressable, EventEmitterable<ContractEvent
Object.defineProperty(this, internal, { value: { } });
let addrPromise;
let addr = null;
let addr: null | string = null;
let deployTx: null | ContractTransactionResponse = null;
if (_deployTx) {

@ -907,7 +907,8 @@ export class AbstractProvider implements Provider {
})())
});
let maxFeePerGas = null, maxPriorityFeePerGas = null;
let maxFeePerGas: null | bigint = null;
let maxPriorityFeePerGas: null | bigint = null;
// These are the recommended EIP-1559 heuristics for fee data
const block = this._wrapBlock(_block, network);

@ -332,7 +332,7 @@ function getFuzzyMode(quorum: number, results: Array<TallyResult>): undefined |
}
let bestWeight = 0;
let bestResult = undefined;
let bestResult: undefined | number = undefined;
for (const { weight, result } of tally.values()) {
// Use this result, if this result meets quorum and has either:

@ -27,7 +27,7 @@ type Decoded = {
};
function _decodeChildren(data: Uint8Array, offset: number, childOffset: number, length: number): Decoded {
const result = [];
const result: Array<any> = [];
while (childOffset < offset + 1 + length) {
const decoded = _decode(data, childOffset);

@ -6,7 +6,7 @@ import type { RlpStructuredData } from "./rlp.js";
function arrayifyInteger(value: number): Array<number> {
const result = [];
const result: Array<number> = [];
while (value) {
result.unshift(value & 0xff);
value >>= 8;

@ -162,8 +162,8 @@ function getUtf8CodePoints(_bytes: BytesLike, onError?: Utf8ErrorFunc): Array<nu
}
// Multibyte; how many bytes left for this character?
let extraLength = null;
let overlongMask = null;
let extraLength: null | number = null;
let overlongMask: null | number = null;
// 110x xxxx 10xx xxxx
if ((c & 0xe0) === 0xc0) {
@ -253,7 +253,7 @@ export function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8
str = str.normalize(form);
}
let result = [];
let result: Array<number> = [];
for (let i = 0; i < str.length; i++) {
const c = str.charCodeAt(i);

@ -49,7 +49,7 @@ function toString(data: Array<number>): string {
function loadWords(): Array<string> {
if (_wordlist !== null) { return _wordlist; }
const wordlist = [];
const wordlist: Array<string> = [];
// Transforms for normalizing (sort is a not quite UTF-8)
const transform: { [key: string]: string | boolean } = {};
@ -91,7 +91,7 @@ function loadWords(): Array<string> {
for (let length = 3; length <= 9; length++) {
const d = data[length - 3];
for (let offset = 0; offset < d.length; offset += length) {
const word = [];
const word: Array<number> = [];
for (let i = 0; i < length; i++) {
const k = mapping.indexOf(d[offset + i]);
word.push(227);

@ -24,7 +24,7 @@ const style = "~!@#$%^&*_-=[]{}|;:,.()<>?"
function loadWords(locale: string): Array<string> {
if (_wordlist[locale] != null) { return _wordlist[locale] as Array<string>; }
const wordlist = [];
const wordlist: Array<string> = [];
let deltaOffset = 0;
for (let i = 0; i < 2048; i++) {