fix(studio): published types never name a dependency by a node_modules path - #5050
Closed
miguel-heygen wants to merge 2 commits into
Closed
miguel-heygen wants to merge 2 commits into
miguel-heygen wants to merge 2 commits into
Conversation
Edit accuracy: accurate 2040 (base branch 2040), smooth 1701 of thoseThe gate passes. Quarantined, measured but not gated (0) |
Collaborator
Author
|
Folded into #5048 (same two commits), so it lands with that PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
@hyperframes/studio's published types namecn's type through thecnpackage's public entry. Before, they imported it from a path insidenode_modules, which does not resolve for a consumer. On some runners the type build refused to emit it at all, so Studio's build failed.Why
cninpackages/studio/src/components/ui/cn.tshad no type annotation, so the declaration build inferredcreateCn's return type and named it by where it found it:Where that path is not reachable from the package, TypeScript stops with TS2742 instead ("The inferred type of 'cn' cannot be named without a reference to '…/node_modules/cn/dist/types'"). That made Studio's build fail intermittently in the Windows render check, on a PR that does not touch Studio.
How
Two changes, each fixing its own half:
cnis annotated withCnFunction, which thecnpackage exports from its public entry. TypeScript no longer has to name an inferred type, so it never reaches TS2742, wherevercnis installed:baseUrl. Studio's tsconfig set"baseUrl": ".". That is what let the declaration build write a barenode_modules/...import where it should have stopped. Its only use was the@hyperframes/playerpath alias, which resolves relative to the tsconfig without it. With it removed, a future export like this one still gets portable types on Linux, where the dts bundler writes the type into Studio's own declarations, and fails the build loudly where it cannot. It can no longer ship broken silently.No visible change
Types and build config only. The value and the runtime bundle are unchanged.
Test plan
packages/studioon main:dist/ui.d.tsimports from'node_modules/cn/dist/types'.dist/ui.d.tsimportsCnFunctionfrom'cn', and the build passes.baseUrl, unannotated. Main'scn.tswithbaseUrlremoved builds on Linux, anddist/ui.d.tsdeclaresCnFunctionitself with nonode_modulesimport. Wherecnresolves only from the repo root, as on the Windows runner, that same build still fails with TS2742, which is why the annotation is needed too.baseUrl, and Studio's typecheck passes.