Commit 96b3cd3
authored
fix: clean up ComponentOverrides types to not leak displayName (#3551)
## 🎯 Goal
Components with `.displayName` assignments (e.g.
`ChannelPreviewView.displayName = '...'`) caused `typeof` to include
`displayName: string` (required) in the inferred `DEFAULT_COMPONENTS`
type. This leaked into `ComponentOverrides`, forcing integrators to set
`displayName` on their custom component overrides.
## 🛠 Implementation details
- **`NormalizeComponents` mapped type** — normalizes each entry in
`DEFAULT_COMPONENTS` to `React.ComponentType<P>`, where `displayName` is
optional (`displayName?: string`). Applied via a typed cast on the
export so the raw object keeps its runtime shape.
- **`OptionalComponentOverrides` interface** — optional component slots
(no default implementation) are moved out of the runtime object into a
standalone interface. This eliminates `undefined as
React.ComponentType<any> | undefined` casts and `eslint-disable`
comments.
- **Proper props types** — `MessageLocation`, `MessageText`, and `Input`
now have real prop types instead of `React.ComponentType<any>`.
Components rendered with no props use `React.ComponentType` (defaults to
`{}`).
- **Removed stale `PLAN.md`** from the componentsContext directory.
## 🎨 UI Changes
No UI changes — types only.
## 🧪 Testing
- `npx tsc --noEmit` passes with zero errors
- Verified via TS compiler API that `ChannelPreview` on
`DEFAULT_COMPONENTS` resolves to `ComponentType<...>` with
`?displayName: string | undefined` (optional)
## ☑️ Checklist
- [x] I have signed the [Stream
CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform)
(required)
- [x] PR targets the `develop` branch
- [ ] Documentation is updated
- [x] New code is tested in main example apps, including all possible
scenarios
- [ ] SampleApp iOS and Android
- [ ] Expo iOS and Android1 parent a9c64d9 commit 96b3cd3
File tree
4 files changed
+49
-229
lines changed- package/src/contexts/componentsContext
- __tests__
4 files changed
+49
-229
lines changedLines changed: 2 additions & 1 deletion
| 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 | | |
| |||
This file was deleted.
Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 47 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
150 | | - | |
151 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
152 | 157 | | |
153 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
154 | 163 | | |
155 | 164 | | |
156 | 165 | | |
| |||
300 | 309 | | |
301 | 310 | | |
302 | 311 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
| 312 | + | |
334 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
0 commit comments