Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typescript types in several files #4159

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src.ts/_admin/test-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const TestData = (function() {
return [ String(data.length), zlib.deflateRawSync(data).toString("base64") ].join(",");
}

let data = [ ];
let data: any = [ ];
data.push(`import { ethers } from "/index.js";`);
data.push(`import { inflate } from "/static/tiny-inflate.js";`);
data.push(`const fs = new Map();`);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/_tests/test-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe("Test Typed Contract Interaction", function() {
}
];

const abi = [ ];
const abi: any = [ ];
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)`);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/_tests/test-wallet-mnemonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function fromHex(hex: string): string {
}

function repeat(text: string, length: number): Array<string> {
const result = [ ];
const result: any = [ ];
while (result.length < length) { result.push(text); }
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src.ts/abi/coders/abstract-coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class Result extends Array<any> {
}
if (end > this.length) { end = this.length; }

const result = [ ], names = [ ];
const result: any = [ ], names: any = [ ];
for (let i = start; i < end; i++) {
result.push(this[i]);
names.push(this.#names[i]);
Expand All @@ -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: any = [ ], names: any = [ ];
for (let i = 0; i < this.length; i++) {
const item = this[i];
if (item instanceof Error) {
Expand Down
4 changes: 2 additions & 2 deletions src.ts/abi/coders/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class ArrayCoder extends Coder {

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

let coders = [];
let coders: any = [];
for (let i = 0; i < value.length; i++) { coders.push(this.coder); }

return pack(writer, coders, value);
Expand All @@ -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: any = [];
for (let i = 0; i < count; i++) { coders.push(new AnonymousCoder(this.coder)); }

return unpack(reader, coders);
Expand Down
8 changes: 4 additions & 4 deletions src.ts/abi/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,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(""); }
Expand Down Expand Up @@ -1061,7 +1061,7 @@ export class ErrorFragment extends NamedFragment {
});
}

const result = [ ];
const result: any = [ ];
if (format !== "sighash") { result.push("error"); }
result.push(this.name + joinParams(format, this.inputs));
return result.join(" ");
Expand Down Expand Up @@ -1136,7 +1136,7 @@ export class EventFragment extends NamedFragment {
});
}

const result = [ ];
const result: any = [ ];
if (format !== "sighash") { result.push("event"); }
result.push(this.name + joinParams(format, this.inputs));
if (format !== "sighash" && this.anonymous) { result.push("anonymous"); }
Expand Down Expand Up @@ -1435,7 +1435,7 @@ export class FunctionFragment extends NamedFragment {
});
}

const result = [];
const result: any = [];

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

Expand Down
6 changes: 3 additions & 3 deletions src.ts/abi/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: any = [ ];
for (const [ name, fragment ] of this.#events) {
if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); }
}
Expand Down Expand Up @@ -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: any = [ ];
for (const [ name, fragment ] of this.#errors) {
if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); }
}
Expand Down Expand Up @@ -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: Indexed | null = null;
if (param.indexed) {
if (resultIndexed == null) {
value = new Indexed(null);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/contract/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,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) {
Expand Down
2 changes: 1 addition & 1 deletion src.ts/providers/abstract-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ export class AbstractProvider implements Provider {
})())
});

let maxFeePerGas = null, maxPriorityFeePerGas = null;
let maxFeePerGas: bigint | null = null, maxPriorityFeePerGas: bigint | null = null;

if (block && block.baseFeePerGas) {
// We may want to compute this more accurately in the future,
Expand Down
2 changes: 1 addition & 1 deletion src.ts/providers/provider-fallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function getFuzzyMode(quorum: number, results: Array<TallyResult>): undefined |
}

let bestWeight = 0;
let bestResult = undefined;
let bestResult: number | undefined = undefined;

for (const { weight, result } of tally.values()) {
// Use this result, if this result meets quorum and has either:
Expand Down
2 changes: 1 addition & 1 deletion src.ts/utils/rlp-decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Decoded = {
};

function _decodeChildren(data: Uint8Array, offset: number, childOffset: number, length: number): Decoded {
const result = [];
const result: any = [];

while (childOffset < offset + 1 + length) {
const decoded = _decode(data, childOffset);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/utils/rlp-encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { RlpStructuredData } from "./rlp.js";


function arrayifyInteger(value: number): Array<number> {
const result = [];
const result: any = [];
while (value) {
result.unshift(value & 0xff);
value >>= 8;
Expand Down
8 changes: 4 additions & 4 deletions src.ts/utils/utf8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @_subsection api/utils:Strings and UTF-8 [about-strings]
*/
import { getBytes } from "./data.js";
import { HexString, getBytes } from "./data.js";
import { assertArgument, assertNormalize } from "./errors.js";

import type { BytesLike } from "./index.js";
Expand Down Expand Up @@ -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: number | null = null;
let overlongMask: number | null = null;

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

let result = [];
let result: any = [];
for (let i = 0; i < str.length; i++) {
const c = str.charCodeAt(i);

Expand Down
4 changes: 2 additions & 2 deletions src.ts/wordlists/lang-ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function toString(data: Array<number>): string {
function loadWords(): Array<string> {
if (_wordlist !== null) { return _wordlist; }

const wordlist = [];
const wordlist: string[] = [];

// Transforms for normalizing (sort is a not quite UTF-8)
const transform: { [key: string]: string | boolean } = {};
Expand Down Expand Up @@ -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: any = [];
for (let i = 0; i < length; i++) {
const k = mapping.indexOf(d[offset + i]);
word.push(227);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/wordlists/lang-zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: string[] = [];

let deltaOffset = 0;
for (let i = 0; i < 2048; i++) {
Expand Down