Remove explicit any usage and enforce stricter lint/type rules#3831
Remove explicit any usage and enforce stricter lint/type rules#3831MontrealAI wants to merge 1 commit into
any usage and enforce stricter lint/type rules#3831Conversation
| value = BigInt((packed as any).toString()); | ||
| } else if ( | ||
| typeof packed === 'object' && | ||
| packed !== null && |
Check warning
Code scanning / CodeQL
Comparison between inconvertible types Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
In general, this kind of issue is fixed by either (a) removing redundant comparisons that are already guaranteed by previous checks, or (b) restructuring the condition to ensure that values of incompatible types are not being compared in a meaningless way. Here, the function already returns early when packed is null or undefined, so the later comparison packed !== null within the typeof packed === 'object' branch cannot ever be false. That makes the packed !== null part redundant and is what CodeQL is complaining about.
The best fix is to simplify the object branch condition from:
} else if (
typeof packed === 'object' &&
packed !== null &&
'toString' in packed &&
typeof packed.toString === 'function'
) {to:
} else if (
typeof packed === 'object' &&
'toString' in packed &&
typeof packed.toString === 'function'
) {Because null has already been handled at the top of the function, this change does not alter runtime behavior but removes the unnecessary comparison between packed and null. No new methods, imports, or definitions are needed; this is a purely local condition simplification within apps/orchestrator/bidding.ts in the decodePackedJobMetadata function.
| @@ -72,7 +72,6 @@ | ||
| value = BigInt(packed); | ||
| } else if ( | ||
| typeof packed === 'object' && | ||
| packed !== null && | ||
| 'toString' in packed && | ||
| typeof packed.toString === 'function' | ||
| ) { |
| value = BigInt((packed as any).toString()); | ||
| } else if ( | ||
| typeof packed === 'object' && | ||
| packed !== null && |
Check warning
Code scanning / CodeQL
Comparison between inconvertible types Warning
Copilot Autofix
AI 5 months ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| if (typeof value === 'bigint') return value.toString(); | ||
| if ( | ||
| typeof value === 'object' && | ||
| value !== null && |
Check warning
Code scanning / CodeQL
Comparison between inconvertible types Warning
Copilot Autofix
AI 5 months ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| value = BigInt((packed as any).toString()); | ||
| } else if ( | ||
| typeof packed === 'object' && | ||
| packed !== null && |
Check warning
Code scanning / CodeQL
Comparison between inconvertible types Warning
Copilot Autofix
AI 5 months ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| value = BigInt((packed as any).toString()); | ||
| } else if ( | ||
| typeof packed === 'object' && | ||
| packed !== null && |
Check warning
Code scanning / CodeQL
Comparison between inconvertible types Warning
Copilot Autofix
AI 5 months ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
Motivation
anycasts and unsafe type assertions to improve runtime safety and enable stronger static checks.unknownhandling and typed guards so data parsed from external sources is validated before use.anyusage and unsafe catch typings.Description
anyandas anycasts withunknown-aware code, typed guards (isRecord) and safe conversion helpers across orchestrator, validator, console, onebox, arena and shared modules (examples:apps/orchestrator/*,apps/validator/*,apps/console/*,services/arena/*,shared/*).z.unknown()instead ofz.any()for input records and payloads (files:packages/onebox-sdk/src/types.ts,packages/onebox-orchestrator/src/ics/schema.ts,packages/orchestrator/src/ics.ts,services/arena/src/validators.ts).isRecordguards,toStringValue, typed harness interfaces for tests, and EIP-1193window.ethereumtypings (apps/console/src/types/ethereum.d.ts,apps/validator-ui/types/ethereum.d.ts).tsconfig.json(noImplicitAny,useUnknownInCatchVariables) andeslint.config.js(set@typescript-eslint/no-explicit-anytoerrorglobally and permittedanyin test/demo paths), and minor Solidity cleanup (removed an unused ERC20 import).Testing
npm run lint:fixwhich executed ESLint/Prettier fixes and Solhint (warnings only); the lint fix command completed successfully.npm run typecheck --prefix apps/console,--prefix apps/enterprise-portal, and--prefix apps/oneboxand they completed without errors.npm test; unit and integration suites executed and the Hardhat tests completed (Hardhat run finished with tests passing).lint:fix,typecheck, andtest) were exercised and completed successfully in the run.Codex Task