Fix missing TypeScript type declarations in @usex/rule-engine-builder #5
+68
−0
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.
Problem
The
@usex/rule-engine-builderpackage was not generating TypeScript declaration files, causing the following error when importing in TypeScript projects:Despite the package claiming to be "TypeScript Native" with full type safety support, the build process was generating an empty
index.d.tsfile (literally justexport {}), preventing TypeScript users from accessing any type information.Root Cause
The
vite-plugin-dtsplugin was usingtsconfig.app.jsonwhich has"noEmit": true. This compiler option prevents TypeScript from emitting any output files, including declaration files, which meant the plugin could not generate the necessary.d.tsfiles.Solution
1. Created
tsconfig.build.json- A dedicated TypeScript configuration specifically for building the library with proper emission settings:{ "extends": "./tsconfig.app.json", "compilerOptions": { "noEmit": false, "declaration": true, "declarationMap": true, "emitDeclarationOnly": false, "outDir": "dist", "esModuleInterop": true, "allowSyntheticDefaultImports": true }, "include": ["src/**/*.ts", "src/**/*.tsx"], "exclude": ["src/demo.tsx", "src/main.tsx", "src/vite-env.d.ts", ...] }2. Updated
vite.config.ts- Modified thevite-plugin-dtsconfiguration to use the new build-specific TypeScript config:3. Added type export test - Created
test/type-exports.test.tsto verify that all types are properly exported and can be imported without errors.Verification
After this fix:
dist/index.d.tsis now 2.3KB with 31+ properly typed exports (previously was empty)Testing
Tested with a real-world TypeScript React project importing the package - compilation succeeds without errors when using standard TypeScript best practices (
skipLibCheck: true).Closes #[issue-number]
Original prompt
Fixes #3
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.