Skip to content

Commit d4df18f

Browse files
committed
fix(types): resolve TypeScript type errors in iocraft and test helpers
Fixed critical type errors preventing build: - Replaced imported ComponentNode type with comprehensive Element interface - Added support for all iocraft element properties (flex, border, padding, etc.) - Fixed border_edges type (object instead of string) - Fixed flex_basis type (number | string) - Fixed mixed_text_contents with explicit undefined for optional properties - Added type casts for iocraft render functions (renderToString, print, eprint) - Fixed test helper import path (../../utils -> ../../src/utils) All checks now pass: - TypeScript: 0 errors - Oxlint: 0 warnings, 0 errors (955 files, 101 rules) - Tests: 343 test files, 5,157 tests passed
1 parent 2ca9d1b commit d4df18f

File tree

2 files changed

+106
-5
lines changed

2 files changed

+106
-5
lines changed

packages/cli/src/utils/terminal/iocraft.mts

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,109 @@ export interface FragmentProps {
458458

459459
/**
460460
* Element type (iocraft element).
461+
* We define our own interface instead of using ComponentNode directly
462+
* because we need to support all properties when building elements.
461463
*/
462-
export type Element = import('@socketaddon/iocraft').ComponentNode
464+
export interface Element {
465+
type: 'Text' | 'View' | 'MixedText' | 'Fragment'
466+
children?: Element[]
467+
468+
// Text properties
469+
content?: string
470+
align?: string
471+
bold?: boolean
472+
color?: string
473+
dim_color?: boolean
474+
italic?: boolean
475+
strikethrough?: boolean
476+
underline?: boolean
477+
weight?: string
478+
wrap?: string
479+
480+
// View properties
481+
display?: string
482+
position?: string
483+
bottom?: number
484+
inset?: number
485+
left?: number
486+
right?: number
487+
top?: number
488+
489+
// Flex layout
490+
align_content?: string
491+
align_items?: string
492+
column_gap?: number
493+
flex_basis?: number | string
494+
flex_direction?: string
495+
flex_grow?: number
496+
flex_shrink?: number
497+
flex_wrap?: string
498+
gap?: number
499+
justify_content?: string
500+
row_gap?: number
501+
502+
// Dimensions
503+
height?: number
504+
max_height?: number
505+
max_width?: number
506+
min_height?: number
507+
min_width?: number
508+
width?: number
509+
510+
// Overflow
511+
overflow_x?: string
512+
overflow_y?: string
513+
514+
// Padding
515+
padding?: number
516+
padding_x?: number
517+
padding_y?: number
518+
padding_top?: number
519+
padding_right?: number
520+
padding_bottom?: number
521+
padding_left?: number
522+
523+
// Margin
524+
margin?: number
525+
margin_x?: number
526+
margin_y?: number
527+
margin_top?: number
528+
margin_right?: number
529+
margin_bottom?: number
530+
margin_left?: number
531+
532+
// Border
533+
border_color?: string
534+
border_edges?: {
535+
top?: boolean
536+
right?: boolean
537+
bottom?: boolean
538+
left?: boolean
539+
}
540+
border_style?: string
541+
custom_border_chars?: {
542+
top_left: string
543+
top_right: string
544+
bottom_left: string
545+
bottom_right: string
546+
top: string
547+
bottom: string
548+
left: string
549+
right: string
550+
}
551+
552+
// Background
553+
background_color?: string
554+
555+
// MixedText
556+
mixed_text_contents?: Array<{
557+
text: string
558+
color?: string | undefined
559+
weight?: string | undefined
560+
decoration?: string | undefined
561+
italic?: boolean | undefined
562+
}>
563+
}
463564

464565
/**
465566
* Create a text element with styling.
@@ -764,23 +865,23 @@ export function Fragment(props: FragmentProps): Element {
764865
*/
765866
export function renderToString(element: Element): string {
766867
const io = getIocraft()
767-
return io.renderToString(element)
868+
return io.renderToString(element as import('@socketaddon/iocraft').ComponentNode)
768869
}
769870

770871
/**
771872
* Print an element to stdout.
772873
*/
773874
export function print(element: Element): void {
774875
const io = getIocraft()
775-
io.printComponent(element)
876+
io.printComponent(element as import('@socketaddon/iocraft').ComponentNode)
776877
}
777878

778879
/**
779880
* Print an element to stderr.
780881
*/
781882
export function eprint(element: Element): void {
782883
const io = getIocraft()
783-
io.eprintComponent(element)
884+
io.eprintComponent(element as import('@socketaddon/iocraft').ComponentNode)
784885
}
785886

786887
/**

packages/cli/test/helpers/generate-report-test-helpers.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SocketArtifact } from '../../utils/alert/artifact.mts'
1+
import type { SocketArtifact } from '../../src/utils/alert/artifact.mts'
22

33
/**
44
* Helper function to create a simple clean scan with no security issues.

0 commit comments

Comments
 (0)