Right now, the generated TypeScript type definitions for @wikimedia/codex refer to the Icon type, which they import from @wikimedia/codex-icons. However, the @wikimedia/codex package doesn't declare a dependency on @wikimedia/codex-icons, because it doesn't depend on that package at runtime; only the type definitions do. This causes errors for end users using TypeScript, unless they install both packages.
Similarly, with the approach proposed in https://gerrit.wikimedia.org/r/c/design/codex/+/769811 , the new @wikimedia/codex-search package would import all of its type definitions from @wikimedia/codex, but it doesn't formally depend on that package.
I see two possible approaches to solve this problem:
- Add @wikimedia/codex-icons as an NPM dependency of @wikimedia/codex. That's a little misleading, because it's not an actual runtime dependency (the components use some icons, but they embed them rather than getting them from the icons package at runtime), but it would be a simple way to fix the TypeScript issue.
- Find a way to make TypeScript embed imported declarations. This seems to be difficult to do, and consolidating all the type definitions from a package into a single file would probably be a step in that direction, but that also seems to be difficult.
Perhaps we should do #1 for now, and then consider trying #2 later?