Commit 68f7091
refactor: convert reactQueryHelpers folder from Flow to TypeScript (#4357)
* refactor: convert reactQueryHelpers folder from Flow to TypeScript
- Convert all 6 JavaScript files to TypeScript with minimal changes
- Remove Flow type annotations and replace with TypeScript equivalents
- Update imports to use TypeScript syntax (import type)
- Maintain all existing function logic and structure
- Update ResourceQuery type to support function-based id properties
- Follow existing TypeScript patterns from the codebase
Files converted:
- reactQueryHelpers.const.js → .ts
- query/useMetadataQuery.types.js → .ts
- query/useMetadataQuery.js → .ts
- query/useApiDataQuery.js → .ts
- query/index.js → .ts
- index.js → .ts
Co-Authored-By: [email protected] <[email protected]>
* fix: update ResourceQuery type to be compatible with existing codebase
- Use 'any' type for id, data, and params properties to maintain compatibility
- Resolves TypeScript compilation errors in converted reactQueryHelpers files
- Maintains minimal changes approach as requested
Co-Authored-By: [email protected] <[email protected]>
* fix: allow optional ResourceQuery in useApiMetadataQuery to handle conditional queries
- Update useApiMetadataQuery function signature to accept ResourceQuery | undefined
- Add null check in queryFn implementation to return empty object when no query provided
- This fixes TypeScript errors in files using conditional query patterns like useRelationshipTypes.ts
Co-Authored-By: [email protected] <[email protected]>
* fix: update useApiDataQuery to handle optional ResourceQuery parameters
- Allow ResourceQuery | undefined parameter type
- Add enabled: !!queryObject to prevent queries when queryObject is undefined
- Use non-null assertion in queryFn since query is disabled when queryObject is undefined
- This should resolve remaining 'Property X does not exist on type {}' errors
Co-Authored-By: [email protected] <[email protected]>
* fix: return undefined when queryObject is undefined to match React Query disabled query behavior
Co-Authored-By: [email protected] <[email protected]>
* fix: add enabled flag and remove select function for disabled queries
Co-Authored-By: [email protected] <[email protected]>
* fix: simplify query functions to return undefined when queryObject is undefined
Co-Authored-By: [email protected] <[email protected]>
* fix: use enabled flag to prevent query execution when queryObject is undefined
Co-Authored-By: [email protected] <[email protected]>
* fix: return undefined when queryObject is undefined to resolve TypeScript errors
Co-Authored-By: [email protected] <[email protected]>
* fix: update Result type to include undefined for disabled queries
Co-Authored-By: [email protected] <[email protected]>
* fix: ensure enabled flag takes precedence over queryOptions
Co-Authored-By: [email protected] <[email protected]>
* fix: ts errors
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: henrikmv <[email protected]>1 parent b7fc969 commit 68f7091
File tree
24 files changed
+150
-129
lines changed- src/core_modules
- capture-core-utils/types
- capture-core
- components
- DataEntries
- EnrollmentRegistrationEntry
- hooks
- common
- ProgramStage
- TEIAndEnrollment/useMetadataForRegistrationForm/hooks
- MetadataAutoSelectInitializer/hooks
- SearchBox/hooks
- WidgetEnrollment/TransferModal
- OrgUnitField
- hooks
- WidgetRelatedStages/RelatedStagesActions
- WidgetTwoEventWorkspace/hooks
- WidgetsChangelog/common/hooks
- utils/reactQueryHelpers
- query
24 files changed
+150
-129
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
| 85 | + | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
| 74 | + | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments