Skip to content

fix: generate type declarations for all exports with types field#121

Merged
boazpoolman merged 2 commits intostrapi:mainfrom
boazpoolman:fix/type-declarations-for-custom-exports
Apr 1, 2026
Merged

fix: generate type declarations for all exports with types field#121
boazpoolman merged 2 commits intostrapi:mainfrom
boazpoolman:fix/type-declarations-for-custom-exports

Conversation

@boazpoolman
Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: vite-plugin-dts was only set up when a per-bundle tsconfig existed at a hardcoded path (e.g. ./admin/tsconfig.build.json, ./server/tsconfig.build.json). These are auto-generated by init, but custom exports (e.g. ./types) never get one, so type generation silently failed.
  • Fix: Added a tsconfig fallback chain in vite-config.ts — per-bundle tsconfig → root tsconfig.build.json → root tsconfig.json. Any export with a types field now generates .d.ts files as long as any tsconfig is present in the project.
  • Test fixture: Added missing tsconfig files to custom-export-plugin and a new assertion that dist/types/index.d.ts is produced after building.

Test plan

  • Run pnpm run test:unit — new test should generate type declarations for custom exports with types field passes
  • Build a plugin with a custom export that has a types field and confirm .d.ts is present in dist/
  • Confirm existing admin/server type generation is unaffected (per-bundle tsconfig still takes priority)

🤖 Generated with Claude Code

Previously, vite-plugin-dts was only set up when a per-bundle tsconfig
existed (e.g. ./admin/tsconfig.build.json or ./server/tsconfig.build.json).
Custom exports like ./types silently produced no .d.ts files because their
tsconfig was never generated by the init command.

The fix adds a fallback chain: per-bundle tsconfig → root tsconfig.build.json
→ root tsconfig.json. Any export with a types field will now generate
declarations as long as any tsconfig is present in the project.

Also adds tsconfig files to the custom-export-plugin fixture and a test
that asserts index.d.ts is produced for the ./types custom export.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 30, 2026

🦋 Changeset detected

Latest commit: b8d289b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@strapi/sdk-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@boazpoolman boazpoolman requested a review from jhoward1994 March 30, 2026 09:27
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@jhoward1994 jhoward1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍🏻

@boazpoolman boazpoolman merged commit 209eae4 into strapi:main Apr 1, 2026
4 checks passed
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.

2 participants