You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MIGRATION_GUIDE.md
+33-27Lines changed: 33 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,11 @@ This document describes the approach for incrementally migrating `@dhis2/ui` com
6
6
7
7
## Key Findings
8
8
9
-
-**Build system**: `d2-app-scripts build` uses Babel with `@babel/preset-typescript` already included — it can compile `.ts`/`.tsx` out of the box.
10
-
-**styled-jsx**: Ships TypeScript definitions that augment React's `StyleHTMLAttributes` with `jsx` and `global` props. Works in `.tsx` files with the `"types": ["styled-jsx"]` tsconfig option.
11
-
-**Existing types**: Each component has hand-written `.d.ts` files in a `types/` directory. After migration, these can be auto-generated from source via `tsc --declaration`.
12
-
-**ESLint**: The project uses `@dhis2/cli-style` (ESLint 7.x). TypeScript linting works via `@typescript-eslint/parser` v6 + `@typescript-eslint/eslint-plugin` v6.
13
-
-**One quirk**: `d2-app-scripts build` doesn't rename `.tsx` → `.js` in build output. A `post-build-rename.js` script handles this.
9
+
-**Build system**: `d2-app-scripts build` uses Babel with `@babel/preset-typescript` already included — it can compile `.ts`/`.tsx` out of the box.
10
+
-**styled-jsx**: Ships TypeScript definitions that augment React's `StyleHTMLAttributes` with `jsx` and `global` props. Works in `.tsx` files with the `"types": ["styled-jsx"]` tsconfig option.
11
+
-**Existing types**: Each component has hand-written `.d.ts` files in a `types/` directory. After migration, these can be auto-generated from source via `tsc --declaration`.
12
+
-**ESLint**: The project uses `@dhis2/cli-style` (ESLint 7.x). TypeScript linting works via `@typescript-eslint/parser` v6 + `@typescript-eslint/eslint-plugin` v6.
13
+
-**One quirk**: `d2-app-scripts build` doesn't rename `.tsx` → `.js` in build output. A `post-build-rename.js` script handles this.
14
14
15
15
## How to Migrate a Component
16
16
@@ -23,26 +23,32 @@ This document describes the approach for incrementally migrating `@dhis2/ui` com
|`scripts/post-build-rename.js`| Renames `.tsx`/`.ts` → `.js` in build output|
83
89
84
90
## Dev Dependencies Added
85
91
86
-
-`typescript`~5.4.5
87
-
-`@typescript-eslint/parser` ^6
88
-
-`@typescript-eslint/eslint-plugin` ^6
89
-
-`eslint-import-resolver-typescript` ^3
92
+
-`typescript`~5.4.5
93
+
-`@typescript-eslint/parser` ^6
94
+
-`@typescript-eslint/eslint-plugin` ^6
95
+
-`eslint-import-resolver-typescript` ^3
90
96
91
97
## Migration Order Recommendation
92
98
@@ -103,6 +109,6 @@ Start with leaf components (no internal deps) and work up:
103
109
104
110
## Notes
105
111
106
-
- Stories and E2E feature files can stay as `.js` — they don't need to be migrated immediately.
107
-
- The `types/index.d.ts` hand-written files can eventually be replaced by auto-generated declarations from `tsc --declaration`.
108
-
- The `import/extensions` ESLint rule is disabled for `.ts`/`.tsx` files because the codebase convention is to import with `.js` extensions (which Babel resolves to the actual `.tsx` files).
112
+
-Stories and E2E feature files can stay as `.js` — they don't need to be migrated immediately.
113
+
-The `types/index.d.ts` hand-written files can eventually be replaced by auto-generated declarations from `tsc --declaration`.
114
+
-The `import/extensions` ESLint rule is disabled for `.ts`/`.tsx` files because the codebase convention is to import with `.js` extensions (which Babel resolves to the actual `.tsx` files).
0 commit comments