fix: some components missing generated types in package - #767
Open
AaronC81 wants to merge 2 commits into
Open
Conversation
Matches TypeScript's default configuration too. Fixes types of components made by `styled` calls in the generated .d.ts files. Symlinks are relevant because pnpm symlinks from node_modules to the real modules.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
6 tasks
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.



How to review this PR
Leave this text block for the reviewer
Add your PR description below
Problem
The generated types.d.ts file of current oak-components packages is missing types for some components:
This happens for any component which is a direct export of a call to
styled:In total, I counted 23 affected components (expand to see them).
OakBoxOakFieldsetOakFormOakLabelOakTextAreaOakFlexOakGridOakGridAreaOakMaxWidthOakScreenReaderOakHeadingOakFocusIndicatorOakAnchorTargetOakSpanOakRadioTileOakDownloadsJourneyChildSubjectTierSelectorOakHeaderHeroOakSideMenuNavLinkOakLIOakOLOakPOakTypographyOakULThis meant that IDE autocomplete wasn't working in VS Code for these components, and type-checking wasn't running.
Solution
I'm fairly sure this is the issue: Swatinem/rollup-plugin-dts#405
The Rollup plugin we're using to generate types.d.ts doesn't follow the symlinks that pnpm uses to store packages. This means it can't find a definition for
styledto work out the type of these components.This is fixed by setting
preserveSymlinkstofalseas described in that issue.There was one random export which didn't have enough type information any more (errored on
pnpm build), so I'll filled that in.Impact
This may cause errors in projects that consume oak-components, because some components were not being type-checked for some time.
For example, there are 3 errors in OWA with this PR applied, fortunately all seem easy to fix:
src/components/GenericPagesComponents/OaksImpactCaseStudies/index.tsx-OakGridArea's$colStartprop is givenundefinedinstead ofnullsrc/components/SharedComponents/VideoPlayer/VideoPlayer.tsx-VideoPlayer's$bapassed asborder-nonebut this isn't a valid token (I think it'sborder-solid-none)src/pages/about-us/case-studies/[slug].tsx-OakBoxpassed a$gap(with one child, so not doing anything anyway)