Skip to content

Commit 66ffb83

Browse files
mackenziemcclaskeyMackenzie Fernandezclaude
authored
fix(examples): resolve type errors and gate examples typecheck in CI (#111)
Co-authored-by: Mackenzie Fernandez <mackenzie.fernandez@workday.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0a52a70 commit 66ffb83

11 files changed

Lines changed: 25 additions & 24 deletions

File tree

.justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ check:
1313
npx prettier --check .
1414
npx tsc --noEmit
1515
npx eslint src/ cli/src/
16+
cd examples && just setup && npx tsc --noEmit -p tsconfig.json
1617

1718
# Build package to dist/
1819
build:

examples/.justfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
setup:
55
cd hello && npm install
66
cd directory && npm install
7+
cd charitable-donations && npm install
8+
cd create-work-event && npm install
79

810
# Format example source files
911
tidy:

examples/charitable-donations/pages/CharityDetail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export default function CharityDetailPage() {
165165
return (
166166
<Flex flexDirection="column" gap="m" padding="m" maxWidth="800px" margin="0 auto">
167167
<Flex justifyContent="space-between" alignItems="center" flexWrap="wrap" gap="s">
168-
<SecondaryButton onClick={() => navigate(home, {})}>← Back to charities</SecondaryButton>
168+
<SecondaryButton onClick={() => navigate(home)}>← Back to charities</SecondaryButton>
169169
{!editing && <SecondaryButton onClick={startEditing}>Edit charity</SecondaryButton>}
170170
</Flex>
171171

examples/create-work-event/pages/BrowseEvents.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export default function BrowseEventsPage() {
177177
<div style={pageStyle}>
178178
<div style={containerStyle}>
179179
<div style={errorStyle}>Error loading events: {error.message}</div>
180-
<button style={buttonStyle} onClick={() => navigate(home, {})}>
180+
<button style={buttonStyle} onClick={() => navigate(home)}>
181181
← Back to Home
182182
</button>
183183
</div>
@@ -207,7 +207,7 @@ export default function BrowseEventsPage() {
207207
Clear Filter
208208
</button>
209209
)}
210-
<button type="button" style={buttonStyle} onClick={() => navigate(home, {})}>
210+
<button type="button" style={buttonStyle} onClick={() => navigate(home)}>
211211
← Home
212212
</button>
213213
</div>
@@ -220,7 +220,7 @@ export default function BrowseEventsPage() {
220220
) : events.length === 0 ? (
221221
<div style={emptyStyle}>
222222
<p style={{ fontSize: '18px', marginBottom: '16px' }}>No events available</p>
223-
<button style={buttonStyle} onClick={() => navigate(home, {})}>
223+
<button style={buttonStyle} onClick={() => navigate(home)}>
224224
Back to Home
225225
</button>
226226
</div>

examples/create-work-event/pages/CreateEvent.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,7 @@ export default function CreateEventPage() {
313313
</div>
314314

315315
<div style={buttonGroupStyle}>
316-
<button
317-
type="button"
318-
style={buttonStyle('secondary')}
319-
onClick={() => navigate(home, {})}
320-
>
316+
<button type="button" style={buttonStyle('secondary')} onClick={() => navigate(home)}>
321317
Cancel
322318
</button>
323319
<button type="submit" style={buttonStyle('primary')} disabled={isSubmitting}>

examples/create-work-event/pages/EventDetail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export default function EventDetailPage() {
152152
<div style={containerStyle}>
153153
<div style={headerStyle}>
154154
<h1>Event Details</h1>
155-
<button style={buttonStyle('secondary')} onClick={() => navigate(home, {})}>
155+
<button style={buttonStyle('secondary')} onClick={() => navigate(home)}>
156156
← Home
157157
</button>
158158
</div>

examples/create-work-event/pages/Home.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ export default function HomePage() {
113113
const goMyEvents = (e: MouseEvent<HTMLButtonElement>) => {
114114
e.preventDefault();
115115
e.stopPropagation();
116-
navigate(myEvents, {});
116+
navigate(myEvents);
117117
};
118118

119119
const goCreateEvent = (e: MouseEvent<HTMLButtonElement>) => {
120120
e.preventDefault();
121121
e.stopPropagation();
122-
navigate(createEvent, {});
122+
navigate(createEvent);
123123
};
124124

125125
const goManageEvents = (e: MouseEvent<HTMLButtonElement>) => {
126126
e.preventDefault();
127127
e.stopPropagation();
128-
navigate(manageEvents, {});
128+
navigate(manageEvents);
129129
};
130130

131131
return (

examples/create-work-event/pages/ManageEvents.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default function ManageEventsPage() {
9595
inactive: { bg: '#f3e5f5', color: '#7b1fa2' },
9696
draft: { bg: '#fff3e0', color: '#f57c00' },
9797
};
98-
const theme = colors[status] || colors.inactive;
98+
const theme = colors[status] ?? { bg: '#f3e5f5', color: '#7b1fa2' };
9999
return {
100100
display: 'inline-block',
101101
padding: '4px 12px',
@@ -127,7 +127,7 @@ export default function ManageEventsPage() {
127127
<div style={containerStyle}>
128128
<div style={headerStyle}>
129129
<h1 style={titleStyle}>All Events</h1>
130-
<button style={buttonStyle('secondary')} onClick={() => navigate(home, {})}>
130+
<button style={buttonStyle('secondary')} onClick={() => navigate(home)}>
131131
← Home
132132
</button>
133133
</div>
@@ -151,7 +151,7 @@ export default function ManageEventsPage() {
151151
: `${myEvents.length} event${myEvents.length !== 1 ? 's' : ''}`}
152152
</p>
153153
</div>
154-
<button style={buttonStyle('secondary')} onClick={() => navigate(home, {})}>
154+
<button style={buttonStyle('secondary')} onClick={() => navigate(home)}>
155155
← Home
156156
</button>
157157
</div>

examples/create-work-event/pages/MyEvents.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default function MyEventsPage() {
8383
today: { bg: '#fff3e0', color: '#f57c00' },
8484
past: { bg: '#f3e5f5', color: '#7b1fa2' },
8585
};
86-
const theme = colors[status] || colors.upcoming;
86+
const theme = colors[status] ?? { bg: '#e3f2fd', color: '#1976d2' };
8787
return {
8888
padding: '6px 12px',
8989
background: theme.bg,
@@ -126,7 +126,7 @@ export default function MyEventsPage() {
126126
<div style={containerStyle}>
127127
<div style={headerStyle}>
128128
<h1 style={titleStyle}>Registered Events</h1>
129-
<button style={buttonStyle('secondary')} onClick={() => navigate(home, {})}>
129+
<button style={buttonStyle('secondary')} onClick={() => navigate(home)}>
130130
← Home
131131
</button>
132132
</div>
@@ -152,7 +152,7 @@ export default function MyEventsPage() {
152152
: `${registeredEvents.length} event${registeredEvents.length !== 1 ? 's' : ''} with registrations`}
153153
</p>
154154
</div>
155-
<button style={buttonStyle('secondary')} onClick={() => navigate(home, {})}>
155+
<button style={buttonStyle('secondary')} onClick={() => navigate(home)}>
156156
← Home
157157
</button>
158158
</div>
@@ -166,7 +166,7 @@ export default function MyEventsPage() {
166166
<p style={{ fontSize: '18px', marginBottom: '16px' }}>
167167
No events currently have registrations
168168
</p>
169-
<button style={buttonStyle('primary')} onClick={() => navigate(home, {})}>
169+
<button style={buttonStyle('primary')} onClick={() => navigate(home)}>
170170
Browse Events
171171
</button>
172172
</div>

src/data/useQuery.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ export interface QueryOptions {
88
}
99

1010
export interface QueryResult<T> {
11-
data: T[] | T | null;
11+
data: T | null;
1212
loading: boolean;
1313
error: Error | null;
1414
refetch: () => void;
1515
}
1616

17-
export function useQuery<T>(model: string, options?: QueryOptions): QueryResult<T> {
17+
export function useQuery<T>(model: string, options: QueryOptions & { id: string }): QueryResult<T>;
18+
export function useQuery<T>(model: string, options?: QueryOptions): QueryResult<T[]>;
19+
export function useQuery<T>(model: string, options?: QueryOptions): QueryResult<T | T[]> {
1820
const { resolver, invalidationKey } = useDataContext();
19-
const [data, setData] = useState<T[] | T | null>(null);
21+
const [data, setData] = useState<T | T[] | null>(null);
2022
const [loading, setLoading] = useState(true);
2123
const [error, setError] = useState<Error | null>(null);
2224

0 commit comments

Comments
 (0)