You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replaces non-null assertions (!) with explicit guard-and-throw checks in the Limitless exchange class for optional fetcher/normalizer methods. The methods (fetchRawOHLCV, fetchRawOrderBook, fetchRawTrades, fetchRawMyTrades, normalizeOHLCV, normalizeOrderBook, normalizeTrade, normalizeUserTrade, normalizePosition) are declared as optional in the ExchangeFetcher/ExchangeNormalizer interfaces, so the non-null assertions were suppressing real type-safety.
Blast Radius
Core exchange: Limitless only (core/src/exchanges/limitless/index.ts)
All 9 non-null assertions are replaced with proper guards. Error messages are descriptive ("fetchRawOHLCV is not implemented for this exchange").
For fetchTrades and fetchMyTrades, the normalizer method is captured to a local variable before the .map() call (const normalizeTrade = this.normalizer.normalizeTrade). This is necessary because TypeScript cannot narrow optional methods inside callback closures. Correct pattern.
For fetchPositions, the same local-variable capture pattern is used for normalizePosition. Consistent.
The fetchRawPositions call on line 440 does NOT get a guard -- this is correct because fetchRawPositions is a non-optional method in the interface (it's always implemented).
The Limitless fetcher/normalizer actually implement all these methods (confirmed via grep of fetcher.ts and normalizer.ts), so the guards will never fire at runtime today. But they provide correct type-safety if the interface contracts change.
PMXT Pipeline Check
Field propagation: N/A
OpenAPI sync: N/A
Type safety: OK -- strictly improves type safety by replacing compile-time suppression with runtime validation
Semver Impact
patch -- no API change. The new Error throws replace what would have been TypeError: undefined is not a function at runtime.
Risk
Low. The guards are technically dead code today (Limitless implements all these methods), but they provide correct defense against future interface changes. No behavioral change for working calls.
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
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.
Fixes #560