Repository navigation
Fix code smells: remove casts, typeof branching, and non-null assertions - #38
Merged
Merged
Conversation
- Replace `as unknown as Crypto` double cast in checksum.ts with direct `webcrypto.subtle.digest()` call, avoiding type bridge entirely - Extract `isString()` and `isNodeEnvironment()` type guards into shared utils/env.ts, replacing inline `typeof` checks in zip-loader and gtfs-rt-loader - Replace `unknown[]` with proper `ProtobufTimeRange[]` and `ProtobufEntitySelector[]` types in gtfs-rt-loader interfaces - Refactor `convertKeysToSnakeCase` to use `Object.entries()` instead of `for..in` with `as Record<string, unknown>` cast - Replace `as Record<string, unknown>` widening casts on `stmt.getAsObject()` across all 11 query files with proper `ParamsObject` type from sql.js - Replace `Map.get()!` non-null assertions with optional chaining (`?.`) in rt-trip-updates.ts and stop-times.ts - Replace `this.SQL!.Database()` non-null assertion with explicit guard in gtfs-sqljs.ts https://claude.ai/code/session_01A5mkjjjYzJ6Dib9jX167fR
- Remove unused `string` from `loadGTFSZip()` parameter type; the only caller always passes binary data (string→binary conversion happens upstream in `fetchZip`) - Remove unused `isString` helper from utils/env.ts - Update CHANGELOG.md with all code smell fixes from this branch https://claude.ai/code/session_01A5mkjjjYzJ6Dib9jX167fR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
as unknown as Cryptodouble cast in checksum.ts with directwebcrypto.subtle.digest()call, avoiding type bridge entirelyisString()andisNodeEnvironment()type guards intoshared utils/env.ts, replacing inline
typeofchecks in zip-loaderand gtfs-rt-loader
unknown[]with properProtobufTimeRange[]andProtobufEntitySelector[]types in gtfs-rt-loader interfacesconvertKeysToSnakeCaseto useObject.entries()insteadof
for..inwithas Record<string, unknown>castas Record<string, unknown>widening casts onstmt.getAsObject()across all 11 query files with properParamsObjecttype from sql.jsMap.get()!non-null assertions with optional chaining(
?.) in rt-trip-updates.ts and stop-times.tsthis.SQL!.Database()non-null assertion with explicitguard in gtfs-sqljs.ts
https://claude.ai/code/session_01A5mkjjjYzJ6Dib9jX167fR