Open acharb opened 1 month ago
Describe the bug
When streaming ledgers with typescript the sdk says to expect CollectionPage, however the value received is just the ledger record
Makes it so have to type assert to LedgeRecord in order to use the value properly
What version are you on?
@stellar/stellar-sdk@^12.0.0-rc.2"
To Reproduce
import { Horizon } from "@stellar/stellar-sdk"; const streamTest = async () => { const horizon = new Horizon.Server("https://horizon-testnet.stellar.org"); horizon .ledgers() .cursor("now") .limit(200) .stream({ onmessage: async ( msg: Horizon.ServerApi.CollectionPage<Horizon.ServerApi.LedgerRecord>, ) => { console.log(msg.closed_at); // throws error that .closed_at does not exist }, }); }; streamTest();
In order to resolve have to do:
const streamTest = async () => { const horizon = new Horizon.Server("https://horizon-testnet.stellar.org"); horizon .ledgers() .cursor("now") .limit(200) .stream({ onmessage: async (msg: any) => { console.log((msg as Horizon.ServerApi.LedgerRecord).closed_at); }, }); }; streamTest();
Trying to declare the param as LedgerRecord like so:
msg: Horizon.ServerApi.LedgerRecord
throws an error at compile time
Expected behavior
The onMessage value type should be LedgerRecord
Describe the bug
When streaming ledgers with typescript the sdk says to expect CollectionPage, however the value received is just the ledger record
Makes it so have to type assert to LedgeRecord in order to use the value properly
What version are you on?
@stellar/stellar-sdk@^12.0.0-rc.2"
To Reproduce
In order to resolve have to do:
Trying to declare the param as LedgerRecord like so:
throws an error at compile time
Expected behavior
The onMessage value type should be LedgerRecord