Skip to content

fix: some components missing generated types in package - #767

Open
AaronC81 wants to merge 2 commits into
mainfrom
fix/generated-types
Open

fix: some components missing generated types in package#767
AaronC81 wants to merge 2 commits into
mainfrom
fix/generated-types

Conversation

@AaronC81

Copy link
Copy Markdown
Contributor

How to review this PR

Leave this text block for the reviewer

  • Check component hierarchy is followed correctly
  • Check the design Heuristics have been followed
  • Check naming conventions have been applied
  • Check for these gotchyas:
    • Missing exports for Oak components
    • Accidental export of Internal components
    • Snapshots of unexpected components have been modified
    • Circular dependencies
    • Code duplication (via not using base components)
    • Non-functional storybook for this or related components
    • Sensitve files changed eg. atoms, or style tokens
    • Relative imports
    • Default exports

Add your PR description below

Problem

The generated types.d.ts file of current oak-components packages is missing types for some components:

declare const OakBox: any;

This happens for any component which is a direct export of a call to styled:

export const OakBox = styled.div<OakBoxProps>`
  ...
`;
In total, I counted 23 affected components (expand to see them).
  • OakBox
  • OakFieldset
  • OakForm
  • OakLabel
  • OakTextArea
  • OakFlex
  • OakGrid
  • OakGridArea
  • OakMaxWidth
  • OakScreenReader
  • OakHeading
  • OakFocusIndicator
  • OakAnchorTarget
  • OakSpan
  • OakRadioTile
  • OakDownloadsJourneyChildSubjectTierSelector
  • OakHeaderHero
  • OakSideMenuNavLink
  • OakLI
  • OakOL
  • OakP
  • OakTypography
  • OakUL

This meant that IDE autocomplete wasn't working in VS Code for these components, and type-checking wasn't running.

Before After
image image
image image

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 styled to work out the type of these components.

This is fixed by setting preserveSymlinks to false as 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:

  1. src/components/GenericPagesComponents/OaksImpactCaseStudies/index.tsx - OakGridArea's $colStart prop is given undefined instead of null
  2. src/components/SharedComponents/VideoPlayer/VideoPlayer.tsx - VideoPlayer's $ba passed as border-none but this isn't a valid token (I think it's border-solid-none)
  3. src/pages/about-us/case-studies/[slug].tsx - OakBox passed a $gap (with one child, so not doing anything anyway)

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.
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
oak-components-storybook Ready Ready Preview Aug 20, 2026 12:30pm

Request Review

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant