Skip to content

Commit 4f53965

Browse files
committed
fix: resolve TypeScript build errors for publish
- Add ! non-null assertions in agentation-api.preview.e2e.test.ts for noUncheckedIndexedAccess compatibility (sseEvents[0]!, sseEvents[1]!, etc.) - Remove ErrorBoundary class constructor to inherit React.Component's overloaded construct signatures; convert componentDidCatch to arrow function class field for auto-binding - Add // @ts-ignore on ErrorBoundary JSX usages to suppress TS2786: React 19 changed class component types in a way that's incompatible with @opentuah/react's ElementClass check (works correctly at runtime) - Add explicit React.ReactElement return type annotations on exported function components (DiffView, DirectoryTreeView, Dropdown, ReviewApp, ReviewAppView, HunkView, StreamDisplay, App) to fix TS2742 'cannot be named without reference to @types/react' errors
1 parent 48bcebe commit 4f53965

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

cli/src/agentation-api.preview.e2e.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ describe("preview worker Agentation API", () => {
338338
expect(getDeleted.response.status).toBe(404)
339339

340340
const sseEvents = await sseEventsPromise
341-
const createdEvent = asObject(sseEvents[0].data, "sse.created")
342-
const updatedEvent = asObject(sseEvents[1].data, "sse.updated")
343-
const actionEvent = asObject(sseEvents[2].data, "sse.action")
344-
const deletedEvent = asObject(sseEvents[3].data, "sse.deleted")
341+
const createdEvent = asObject(sseEvents[0]!.data, "sse.created")
342+
const updatedEvent = asObject(sseEvents[1]!.data, "sse.updated")
343+
const actionEvent = asObject(sseEvents[2]!.data, "sse.action")
344+
const deletedEvent = asObject(sseEvents[3]!.data, "sse.deleted")
345345

346346
expect(getString(createdEvent, "sessionId", "sse.created")).toBe(sessionId)
347347
expect(getString(updatedEvent, "sessionId", "sse.updated")).toBe(sessionId)

cli/src/cli.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ async function runReviewMode(
760760
// Helper to render with current isGenerating state
761761
const renderApp = (isGenerating: boolean) => {
762762
root.render(
763+
// @ts-ignore - ErrorBoundary class is incompatible with @opentuah/react's ElementClass + React 19 types; works correctly at runtime
763764
<ErrorBoundary>
764765
<ReviewApp hunks={hunks} yamlPath={yamlPath} isGenerating={isGenerating} />
765766
</ErrorBoundary>
@@ -953,6 +954,7 @@ async function runResumeMode(options: ResumeModeOptions) {
953954

954955
const root = createRoot(renderer);
955956
root.render(
957+
// @ts-ignore - ErrorBoundary class is incompatible with @opentuah/react's ElementClass + React 19 types; works correctly at runtime
956958
<ErrorBoundary>
957959
<ReviewApp
958960
hunks={review.hunks}
@@ -1090,6 +1092,7 @@ async function runResumeMode(options: ResumeModeOptions) {
10901092

10911093
const root = createRoot(renderer);
10921094
root.render(
1095+
// @ts-ignore - ErrorBoundary class is incompatible with @opentuah/react's ElementClass + React 19 types; works correctly at runtime
10931096
<ErrorBoundary>
10941097
<ReviewApp
10951098
hunks={review.hunks}
@@ -1381,19 +1384,14 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
13811384
state: ErrorBoundaryState = { hasError: false, error: null };
13821385
declare props: ErrorBoundaryProps;
13831386

1384-
constructor(props: ErrorBoundaryProps) {
1385-
super(props);
1386-
this.componentDidCatch = this.componentDidCatch.bind(this);
1387-
}
1388-
13891387
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
13901388
return { hasError: true, error };
13911389
}
13921390

1393-
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
1394-
console.error("Error caught by boundary:", error);
1395-
console.error("Component stack:", errorInfo.componentStack);
1396-
}
1391+
componentDidCatch = (error: Error, errorInfo: React.ErrorInfo): void => {
1392+
logger.log("Error caught by boundary:", error);
1393+
logger.log("Component stack:", errorInfo.componentStack);
1394+
};
13971395

13981396
render(): React.ReactNode {
13991397
if (this.state.hasError && this.state.error) {
@@ -1474,7 +1472,7 @@ export interface AppProps {
14741472
parsedFiles: ParsedFile[];
14751473
}
14761474
1477-
export function App({ parsedFiles }: AppProps) {
1475+
export function App({ parsedFiles }: AppProps): React.ReactElement {
14781476
const { width: initialWidth } = useTerminalDimensions();
14791477
const [width, setWidth] = React.useState(initialWidth);
14801478
const [scrollAcceleration] = React.useState(() => new ScrollAcceleration());
@@ -2312,6 +2310,7 @@ cli
23122310
}
23132311
23142312
createRoot(renderer).render(
2313+
// @ts-ignore - ErrorBoundary class is incompatible with @opentuah/react's ElementClass + React 19 types; works correctly at runtime
23152314
<ErrorBoundary>
23162315
<AppWithWatch />
23172316
</ErrorBoundary>
@@ -2450,6 +2449,7 @@ cli
24502449
24512450
const renderer = await createCliRenderer();
24522451
createRoot(renderer).render(
2452+
// @ts-ignore - ErrorBoundary class is incompatible with @opentuah/react's ElementClass + React 19 types; works correctly at runtime
24532453
<ErrorBoundary>
24542454
<App parsedFiles={[patchWithRawDiff]} />
24552455
</ErrorBoundary>

cli/src/components/diff-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function getWordHighlightBg(base: RGBA): string {
7070
return rgbaToHex(candidate)
7171
}
7272

73-
export function DiffView({ diff, view, filetype, themeName, wrapMode = "word" }: DiffViewProps) {
73+
export function DiffView({ diff, view, filetype, themeName, wrapMode = "word" }: DiffViewProps): React.ReactElement {
7474
// Balance paired delimiters (backticks, triple quotes, etc.) before
7575
// passing to <diff> so tree-sitter doesn't misparse hunks that start
7676
// inside a multi-line string

cli/src/components/directory-tree-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function DirectoryTreeView({
9999
files,
100100
onFileSelect,
101101
themeName,
102-
}: DirectoryTreeViewProps) {
102+
}: DirectoryTreeViewProps): React.ReactElement | null {
103103
const nodes = React.useMemo(() => buildDirectoryTree(files), [files])
104104
const resolvedTheme = getResolvedTheme(themeName)
105105
const mutedColor = rgbaToHex(resolvedTheme.textMuted)

cli/src/dropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function filterDropdownOptions(options: DropdownOption[], searchText: str
4545
});
4646
}
4747

48-
const Dropdown = (props: DropdownProps) => {
48+
const Dropdown = (props: DropdownProps): React.ReactElement => {
4949
const {
5050
tooltip,
5151
onChange,

cli/src/review/review-app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function ReviewApp({
4747
yamlPath,
4848
isGenerating,
4949
initialReviewData,
50-
}: ReviewAppProps) {
50+
}: ReviewAppProps): React.ReactElement {
5151
const { width } = useTerminalDimensions()
5252
const renderer = useRenderer()
5353
const [reviewData, setReviewData] = React.useState<ReviewYaml | null>(initialReviewData ?? null)
@@ -300,7 +300,7 @@ export function ReviewAppView({
300300
renderer,
301301
gap = 2,
302302
scrollboxRef,
303-
}: ReviewAppViewProps) {
303+
}: ReviewAppViewProps): React.ReactElement {
304304
const [scrollAcceleration] = React.useState(() => new ScrollAcceleration())
305305

306306
// Create a map of hunk ID to hunk for quick lookup
@@ -734,7 +734,7 @@ export interface HunkViewProps {
734734
isLast: boolean
735735
}
736736

737-
export function HunkView({ hunk, themeName, width, isLast }: HunkViewProps) {
737+
export function HunkView({ hunk, themeName, width, isLast }: HunkViewProps): React.ReactElement {
738738
const resolvedTheme = getResolvedTheme(themeName)
739739
const filetype = detectFiletype(hunk.filename)
740740
const { additions, deletions } = countChanges([{ lines: hunk.lines }])

cli/src/review/stream-display.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function StreamDisplay({
2727
notifications,
2828
themeName = "github",
2929
width = 80,
30-
}: StreamDisplayProps) {
30+
}: StreamDisplayProps): React.ReactElement {
3131
const lines = React.useMemo(
3232
() => formatNotifications(notifications),
3333
[notifications],

0 commit comments

Comments
 (0)