Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/commands/analytics/display-analytics.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import fs from 'node:fs/promises'

import { Widgets } from 'blessed'
// @ts-ignore
import ScreenWidget from 'blessed/lib/widgets/screen'
import contrib from 'blessed-contrib'

import { Spinner } from '@socketsecurity/registry/lib/spinner'

import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api'
import { setupSdk } from '../../utils/sdk'

import type { Widgets } from 'blessed' // Note: Widgets does not seem to actually work as code :'(

type FormattedData = {
top_five_alert_types: { [key: string]: number }
total_critical_alerts: { [key: string]: number }
Expand Down Expand Up @@ -98,7 +101,7 @@ export async function displayAnalytics({
}

function displayAnalyticsScreen(data: FormattedData): void {
const screen = new Widgets.Screen({})
const screen: Widgets.Screen = new ScreenWidget({})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be implicit by the return type of ScreenWidget? does it need to be explicitly added to const screen: Widgets.Screen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS is ignoring the import so ScreenWidget is any. But it should be the same value as what I was expecting Widgets.Screen to be, except importing it fails because apparently Widgets ends up as undefined.

This way we get a typed screen variable, mitigating the impact of the ts-ignore.

const grid = new contrib.grid({ rows: 5, cols: 4, screen })

renderLineCharts(
Expand Down
Loading