Skip to content

fix: include all source files for type declaration#117

Merged
jhoward1994 merged 2 commits intomainfrom
fix/vite-include-types
Mar 19, 2026
Merged

fix: include all source files for type declaration#117
jhoward1994 merged 2 commits intomainfrom
fix/vite-include-types

Conversation

@jhoward1994
Copy link
Contributor

@jhoward1994 jhoward1994 commented Mar 17, 2026

What does it do?

Updates the include option for the vite-plugin-dts plugin to match all source files within the entry file's directory, using path.join(path.dirname(bundle.source), '**/*'). This expands type declaration generation from just the entry file to all files in the source folder.

Why is it needed?

By including all source files, all relevant type declarations will be emitted.

How to test it

  1. Create a Strapi plugin with TypeScript types spread across multiple files (e.g., with types imported from sibling modules).
  2. Build the plugin using strapi-plugin build.
  3. Check that the generated dist types directory includes declaration files for all referenced and imported types, not just for the entry point.

Related issue(s) / PR(s)

#115

@changeset-bot
Copy link

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: 69f6aba

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

@sonarqubecloud
Copy link

@jhoward1994 jhoward1994 self-assigned this Mar 17, 2026
@jhoward1994 jhoward1994 requested a review from boazpoolman March 17, 2026 16:29
@jhoward1994 jhoward1994 marked this pull request as ready for review March 17, 2026 16:29
@dosubot
Copy link

dosubot bot commented Mar 17, 2026

Related Documentation

1 document(s) may need updating based on files changed in this PR:

Strapi

development /documentation/blob/main/docusaurus/docs/cms/typescript/development.md
View Suggested Changes
@@ -149,3 +149,7 @@
 :::note
 It is not necessary to repeat the `yarn` or `npm install` command after the initial installation. The `yarn build` or `npm run build` command is necessary to implement any plugin development that affects the admin panel.
 :::
+
+### Type declaration generation
+
+When building TypeScript plugins using the Plugin SDK (`yarn build` or `npm run build`), the build process generates comprehensive type declarations for all source files in the plugin, not just the entry point. All TypeScript types, interfaces, and type definitions used throughout the plugin will have corresponding `.d.ts` declaration files emitted in the build output. This ensures better TypeScript support and IDE autocomplete for developers consuming the plugin.

[Accept] [Decline]

Note: You must be authenticated to accept/decline updates.

How did I do? Any feedback?  Join Discord

Copy link
Collaborator

@boazpoolman boazpoolman left a comment

Choose a reason for hiding this comment

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

Hi @jhoward1994,

I've approved the PR because it solves #115 effectively.

However, there is a related types problem I see with custom exports. For example this Better Auth plugin. It has a custom export called 'adapter' which doesn't get any types in the build directory, even though they are specified in the exports object.

@jhoward1994 jhoward1994 merged commit 6a61df0 into main Mar 19, 2026
7 checks passed
@jhoward1994 jhoward1994 deleted the fix/vite-include-types branch March 19, 2026 13:29
@jhoward1994
Copy link
Contributor Author

@boazpoolman thanks will look into that as a follow up

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