To improve type safety and code clarity, it's best to avoid using any. Let's interfaces for the channel and peers, objects based on the expected structure from the CLN API response.
For example:
interface IClnClosedChannel {
peer_id: string;
total_msat: number;
channel_id: string;
short_channel_id: string;
last_commitment_txid: string;
opener: 'local' | 'remote';
closer: 'local' | 'remote';
private: boolean;
// ... other properties
}
// ...
const formattedClosedChannels = data.closedchannels.map((channel: IClnClosedChannel) => ({
// ...
}));
This leverages TypeScript's strengths to catch potential errors during development and makes the code easier to understand and maintain.
To improve type safety and code clarity, it's best to avoid using
any. Let's interfaces for thechannelandpeers, objects based on the expected structure from the CLN API response.For example:
This leverages TypeScript's strengths to catch potential errors during development and makes the code easier to understand and maintain.