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.
A few things about this PR:
Why build step?
I wanna start this sentence with: We do not need a build step. The files are in .js, and will work in runtime. If you import a .js file exposed from a package, into a .js file in a (say sveltekit) app, the typescript will work well there.
The build step however, is there for two possible future cases:
So, we actually do not need the build step in the present at all, but if in any of the above cases, a build step generating .d.ts files is must.
Why We Migrated From Mixin Composition to Direct Class Implementation
Our HTTP API client previously used the mixin composition pattern, which created several challenges when integrating TypeScript types.
The Problem
The previous approach:
compose(MixinA, MixinB, ...)(BaseClass)
)TypeScript struggled with this pattern because:
this
typing became complex across multiple inheritance layersThe Solution
I consolidated everything into a direct class implementation:
This approach works much better with TypeScript because:
The runtime behavior remains identical, but we get better developer experience, easier maintenance, and reliable bundling.