Skip to content

Commit 2267d46

Browse files
remove anys, add proper types
1 parent a89447a commit 2267d46

File tree

3 files changed

+188
-135
lines changed

3 files changed

+188
-135
lines changed

vscode/extension/src/commands/tableDiff.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { isErr } from '@bus/result'
44
import { CallbackEvent, RPCRequest } from '@bus/callbacks'
55
import { getWorkspaceFolders } from '../utilities/common/vscodeapi'
66

7+
interface ModelInfo {
8+
name: string
9+
fqn: string
10+
description?: string | null
11+
}
12+
713
export function showTableDiff(
814
lspClient?: LSPClient,
915
extensionUri?: vscode.Uri,
@@ -21,7 +27,7 @@ export function showTableDiff(
2127

2228
// Get the current active editor
2329
const activeEditor = vscode.window.activeTextEditor
24-
let selectedModelInfo: any = null
30+
let selectedModelInfo: ModelInfo | null = null
2531

2632
if (!activeEditor) {
2733
// No active editor, show a list of all models
@@ -46,8 +52,8 @@ export function showTableDiff(
4652
}
4753

4854
// Let user choose from all models
49-
const items = (allModelsResult.value.models as any[]).map(
50-
(model: any) => ({
55+
const items = (allModelsResult.value.models as ModelInfo[]).map(
56+
(model: ModelInfo) => ({
5157
label: model.name,
5258
description: model.fqn,
5359
detail: model.description ? model.description : undefined,
@@ -118,6 +124,12 @@ export function showTableDiff(
118124
}
119125
}
120126

127+
// Ensure we have a selected model
128+
if (!selectedModelInfo) {
129+
vscode.window.showErrorMessage('No model selected')
130+
return
131+
}
132+
121133
// Get environments for selection
122134
const environmentsResult = await lspClient.call_custom_method(
123135
'sqlmesh/get_environments',

vscode/react/src/components/tablediff/TableDiff.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import LoadingStatus from '../loading/LoadingStatus'
33
import { TableDiffResults } from './TableDiffResults'
44
import { callRpc } from '../../utils/rpc'
55

6+
// Type for data values in samples - can be strings, numbers, booleans, or null
7+
type SampleValue = string | number | boolean | null
8+
9+
// Type for row data in samples
10+
type SampleRow = Record<string, SampleValue>
11+
12+
// Type for column statistics
13+
type ColumnStats = Record<string, number | string | null>
14+
615
interface TableDiffData {
716
schema_diff: {
817
source: string
@@ -17,19 +26,19 @@ interface TableDiffData {
1726
source: string
1827
target: string
1928
stats: Record<string, number>
20-
sample: Record<string, any>
21-
joined_sample: Record<string, any>
22-
s_sample: Record<string, any>
23-
t_sample: Record<string, any>
24-
column_stats: Record<string, any>
29+
sample: Record<string, SampleValue[]>
30+
joined_sample: Record<string, SampleValue[]>
31+
s_sample: Record<string, SampleValue[]>
32+
t_sample: Record<string, SampleValue[]>
33+
column_stats: ColumnStats
2534
source_count: number
2635
target_count: number
2736
count_pct_change: number
2837
decimals: number
2938
processed_sample_data?: {
30-
column_differences: Array<Record<string, any>>
31-
source_only: Array<Record<string, any>>
32-
target_only: Array<Record<string, any>>
39+
column_differences: SampleRow[]
40+
source_only: SampleRow[]
41+
target_only: SampleRow[]
3342
}
3443
}
3544
on: string[][]

0 commit comments

Comments
 (0)